1 /**
2     \file   ADM_jobProgress
3     \author mean fixounet@free.Fr (c) 2010
4 
5 */
6 /***************************************************************************
7  *                                                                         *
8  *   This program is free software; you can redistribute it and/or modify  *
9  *   it under the terms of the GNU General Public License as published by  *
10  *   the Free Software Foundation; either version 2 of the License, or     *
11  *   (at your option) any later version.                                   *
12  *                                                                         *
13  ***************************************************************************/
14 #include "T_progress.h"
15 #include "ADM_default.h"
16 
17 /**
18     \fn ctor
19 */
jobProgress(uint32_t nbJobs)20 jobProgress::jobProgress(uint32_t nbJobs)
21 {
22     numberOfJobs=nbJobs;
23     currentOutputFile=string("");
24     currentJob=0;
25     percent=0;
26     ui.setupUi(this);
27     ui.progressBar->setMinimum(0);
28     ui.progressBar->setMaximum(100);
29     ui.progressBar->setValue(0);
30     ADM_info("Progress dialog created at %p\n",this);
31 }
32 /**
33     \fn dtor
34 */
~jobProgress()35 jobProgress::~jobProgress()
36 {
37     ADM_info("Deleting progress..\n");
38 }
39 /**
40 
41 */
setCurrentJob(uint32_t job)42 void  jobProgress::setCurrentJob(uint32_t job)
43 {
44     currentJob=job;
45     updateUi();
46 }
47 /**
48 
49 */
setCurrentOutputName(const string & name)50 void  jobProgress::setCurrentOutputName(const string &name)
51 {
52     currentOutputFile=name;
53     updateUi();
54 
55 }
56 /**
57 
58 */
setPercent(uint32_t percent)59 void  jobProgress::setPercent(uint32_t percent)
60 {
61     this->percent=percent;
62     updatePercent();
63 }
64 /**
65 
66 */
updateUi(void)67 void     jobProgress::updateUi(void)
68 {
69     char buffer[128];
70     sprintf(buffer,"%d/%d",currentJob+1,numberOfJobs);
71     ui.labelJobCount->setText(buffer);
72     ui.labelOutputFile_2->setText(currentOutputFile.c_str());
73     updatePercent();
74 }
75 /**
76 
77 */
updatePercent(void)78 void     jobProgress::updatePercent(void)
79 {
80     ui.progressBar->setValue(percent);
81     QApplication::processEvents();
82 }
83 // EOF