process.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include "Core.hh"
00056
00057
00058
00059
00060
00061 void Core::slotStartJob( QString _jobId, QString _description , int _min , int _max, bool _blocking) {
00062 std::cerr << "StartJob: " << _jobId.toStdString() << " " << _description.toStdString() << " " << _min << " " << _max << " " << _blocking <<std::endl;
00063
00064 JobInfo* info = new JobInfo();
00065 info->jobId = _jobId;
00066 info->description = _description;
00067 info->min = _min;
00068 info->max = _max;
00069 info->blocking = _blocking;
00070 info->progressDialog = new QProgressDialog(coreWidget_);
00071 info->progressDialog->setLabelText(_description);
00072 info->progressDialog->setMinimum(_min);
00073 info->progressDialog->setMaximum(_max);
00074 info->progressDialog->setValue(_min);
00075 info->progressDialog->resize(300,130);
00076 info->progressDialog->setMinimumDuration(1);
00077 if ( _blocking )
00078 info->progressDialog->setWindowModality(Qt::WindowModal);
00079
00080 connect( info->progressDialog, SIGNAL(canceled()),
00081 this,SLOT(slotJobCancelButtons()));
00082
00083 currentJobs.push_back(info);
00084
00085 }
00086
00087
00088 bool Core::getJob(QString _jobId, int& _index) {
00089
00090 for ( int i = 0 ; i < currentJobs.size() ; ++i) {
00091 if ( currentJobs[i]->jobId == _jobId ) {
00092 _index = i;
00093 return true;
00094 }
00095 }
00096
00097 emit log(LOGERR,tr("Unable to find Job %1.").arg(_jobId));
00098 _index = -1;
00099 return false;
00100 }
00101
00102
00103
00104
00105 void Core::slotSetJobState(QString _jobId, int _value ) {
00106 int id;
00107
00108 if ( getJob(_jobId, id) ) {
00109 currentJobs[id]->currentState = _value;
00110 currentJobs[id]->progressDialog->setValue(_value);
00111 }
00112 }
00113
00114
00115
00116
00117 void Core::slotCancelJob(QString _jobId ) {
00118 int id;
00119
00120 if ( getJob(_jobId, id) ) {
00121 currentJobs[id]->progressDialog->reset();
00122 currentJobs[id]->progressDialog->hide();
00123 delete currentJobs[id]->progressDialog;
00124 currentJobs.removeAt(id);
00125 }
00126 }
00127
00128
00129
00130
00131 void Core::slotFinishJob(QString _jobId ) {
00132 int id;
00133
00134 if ( getJob(_jobId, id) ) {
00135 currentJobs[id]->progressDialog->reset();
00136 currentJobs[id]->progressDialog->hide();
00137 delete currentJobs[id]->progressDialog;
00138 currentJobs.removeAt(id);
00139 }
00140 }
00141
00142
00143 void Core::slotJobCancelButtons( ) {
00144 for ( int i = 0 ; i < currentJobs.size() ; ++i) {
00145 if ( currentJobs[i]->progressDialog == sender() ) {
00146 QString id = currentJobs[i]->jobId;
00147 slotCancelJob(id);
00148 emit jobCanceled( id );
00149 }
00150 }
00151 }
00152
00153
00154
00155
00156