1 // Copyright (C) 2009-2012 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.
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 BL::Summary::Summary(QWidget *parent, BL::JobsManager_QT * jobs_manager) : QWidget(parent)
25 DEBTRACE("Creating BL::Summary");
27 BL_ASSERT(jobs_manager);
29 _jobs_manager = jobs_manager;
33 QLabel * summary_jobs = new QLabel("Jobs Summary:");
34 QLabel * total_label = new QLabel("Number of jobs:");
35 _total_line = new QLabel;
36 _total_line->setText("0");
38 QLabel * created_label = new QLabel("Number of created jobs:");
39 _created_line = new QLabel;
40 _created_line->setText("0");
42 QLabel * queued_label = new QLabel("Number of queued jobs:");
43 _queued_line = new QLabel;
44 _queued_line->setText("0");
46 QLabel * running_label = new QLabel("Number of running jobs:");
47 _running_line = new QLabel;
48 _running_line->setText("0");
50 QLabel * finished_label = new QLabel("Number of finished jobs:");
51 _finished_line = new QLabel;
52 _finished_line->setText("0");
54 QFormLayout *mainLayout = new QFormLayout;
55 mainLayout->insertRow(0, summary_jobs);
56 mainLayout->insertRow(1, total_label, _total_line);
57 mainLayout->insertRow(2, created_label, _created_line);
58 mainLayout->insertRow(3, queued_label, _queued_line);
59 mainLayout->insertRow(4, running_label, _running_line);
60 mainLayout->insertRow(5, finished_label, _finished_line);
61 setLayout(mainLayout);
64 BL::Summary::~Summary()
66 DEBTRACE("Destroying BL::Summary");
70 BL::Summary::setModel(QStandardItemModel * model)
72 DEBTRACE("Call setModel BL::Summary");
79 BL::Summary::rowsInserted(const QModelIndex & parent, int start, int end)
81 DEBTRACE("BL::Summary::rowsInserted slot");
86 BL::Summary::rowsRemoved(const QModelIndex & parent, int start, int end)
88 DEBTRACE("BL::Summary::rowsRemoved slot");
93 BL::Summary::itemChanged(QStandardItem * item)
99 BL::Summary::updateJobs()
102 QVariant row_number = _model->rowCount();
103 _total_line->setText(row_number.toString());
106 _created_line->setText("0");
107 _queued_line->setText("0");
108 _running_line->setText("0");
109 _finished_line->setText("0");
111 int created_jobs = 0;
113 int running_jobs = 0;
114 int finished_jobs = 0;
115 std::map<std::string, BL::Job *> jobs = _jobs_manager->getJobs();
116 std::map<std::string, BL::Job *>::iterator jobs_it;
117 jobs_it = jobs.begin();
118 for(; jobs_it != jobs.end(); jobs_it++)
120 BL::Job * job = jobs_it->second;
121 BL::Job::State job_state = job->getState();
122 if (job_state == BL::Job::CREATED)
124 if (job_state == BL::Job::QUEUED)
126 if (job_state == BL::Job::RUNNING)
128 if (job_state == BL::Job::FINISHED)
133 _created_line->setText(QVariant(created_jobs).toString());
134 _queued_line->setText(QVariant(queued_jobs).toString());
135 _running_line->setText(QVariant(running_jobs).toString());
136 _finished_line->setText(QVariant(finished_jobs).toString());