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 #include <OpenFlipper/widgets/processManagerWidget/BlockingWidget.hh>
00058
00059
00060
00061
00062
00063 void Core::slotStartJob( QString _jobId, QString _description , int _min , int _max, bool _blocking) {
00064 std::cerr << "StartJob: " << _jobId.toStdString() << " " << _description.toStdString() << " " << _min << " " << _max << " " << _blocking <<std::endl;
00065
00066
00067 JobInfo* info = new JobInfo();
00068 info->id = _jobId;
00069 info->description = _description;
00070 info->currentStep = 0;
00071 info->minSteps = _min;
00072 info->maxSteps = _max;
00073 info->blocking = _blocking;
00074
00075
00076 currentJobs.push_back(info);
00077
00078
00079
00080 if(_blocking) {
00081
00082 BlockingWidget* widget = new BlockingWidget(_jobId, _description,
00083 _min, _max);
00084
00085
00086 connect(widget, SIGNAL(cancelRequested(QString)),
00087 this, SLOT(slotJobCancelRequested(QString)));
00088
00089 info->blockingWidget = widget;
00090
00091
00092 widget->show();
00093
00094 } else {
00095
00096 if(!processManager_) {
00097 processManager_ = new ProcessManagerWidget();
00098
00099
00100 connect(processManager_, SIGNAL(cancelJobRequested(QString)),
00101 this, SLOT(slotJobCancelRequested(QString)));
00102 }
00103
00104
00105 processManager_->addJob(_jobId, _description, _min, _max);
00106
00107
00108 processManager_->show();
00109 }
00110 }
00111
00112
00113 bool Core::getJob(QString _jobId, int& _index) {
00114
00115 for ( int i = 0 ; i < currentJobs.size() ; ++i) {
00116 if ( currentJobs[i]->id == _jobId ) {
00117 _index = i;
00118 return true;
00119 }
00120 }
00121
00122 emit log(LOGERR,tr("Unable to find Job %1.").arg(_jobId));
00123 _index = -1;
00124 return false;
00125 }
00126
00127
00128
00129
00130 void Core::slotSetJobState(QString _jobId, int _value ) {
00131 int id;
00132
00133 if ( getJob(_jobId, id) ) {
00134 currentJobs[id]->currentStep = _value;
00135
00136
00137 if(!currentJobs[id]->blocking)
00138 processManager_->updateStatus(_jobId, _value);
00139 else {
00140 BlockingWidget* w = 0;
00141 w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget);
00142 if(w != 0) {
00143 w->updateStatus(_value);
00144 }
00145 }
00146 }
00147 }
00148
00149
00150
00151
00152 void Core::slotSetJobName(QString _jobId, QString _name ) {
00153 int id;
00154
00155 if ( getJob(_jobId, id) ) {
00156 currentJobs[id]->id = _name;
00157
00158
00159 if(!currentJobs[id]->blocking)
00160 processManager_->setJobName(_jobId, _name);
00161 else {
00162 BlockingWidget* w = 0;
00163 w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget);
00164 if(w != 0) {
00165 w->setJobId(_name);
00166 }
00167 }
00168 }
00169 }
00170
00171
00172
00173 void Core::slotSetJobDescription(QString _jobId, QString _text ) {
00174 int id;
00175
00176 if ( getJob(_jobId, id) ) {
00177 currentJobs[id]->description = _text;
00178
00179
00180 if(!currentJobs[id]->blocking)
00181 processManager_->setJobDescription(_jobId, _text);
00182 else {
00183 BlockingWidget* w = 0;
00184 w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget);
00185 if(w != 0) {
00186 w->setJobDescription(_text);
00187 }
00188 }
00189 }
00190 }
00191
00192
00193
00194
00195 void Core::slotCancelJob(QString _jobId ) {
00196 int id;
00197
00198 if ( getJob(_jobId, id) ) {
00199
00200
00201 if(!currentJobs[id]->blocking)
00202 processManager_->removeJob(_jobId);
00203 else {
00204 BlockingWidget* w = 0;
00205 w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget);
00206 if(w != 0) {
00207 w->hide();
00208 delete w;
00209 }
00210 }
00211
00212 currentJobs.removeAt(id);
00213 }
00214 }
00215
00216
00217
00218
00219 void Core::slotFinishJob(QString _jobId ) {
00220 int id;
00221
00222 if ( getJob(_jobId, id) ) {
00223
00224
00225 if(!currentJobs[id]->blocking)
00226 processManager_->removeJob(_jobId);
00227 else {
00228 BlockingWidget* w = 0;
00229 w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget);
00230 if(w != 0) {
00231 w->hide();
00232 delete w;
00233 }
00234 }
00235
00236 currentJobs.removeAt(id);
00237 }
00238 }
00239
00240
00241
00242
00243 void Core::slotJobCancelRequested(QString ) {
00244
00245
00246 std::cerr << "Cancel requested!" << std::endl;
00247 }
00248
00249