Commit 11ce4d85 authored by Matthias Möller's avatar Matthias Möller

- remove redudant code/speed up

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20244 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 4a0fc737
......@@ -53,86 +53,42 @@
#include <OpenFlipper/common/GlobalOptions.hh>
void ProcessManagerWidget::updateStatus(QString _id, int _status) {
JobContainer job;
std::map<QString, JobContainer>::iterator it = processMap_.begin();
// Find item
bool found = false;
for(; it != processMap_.end(); ++it) {
if((*it).first == _id) {
found = true;
job = (*it).second;
break;
}
}
QHash<QString, JobContainer>::iterator it = processMap_.find(_id);
// No such item has been found -> returning
if(!found) return;
if(it == processMap_.end()) return;
// Set new status
(job.progress)->setValue(_status);
it.value().progress->setValue(_status);
}
void ProcessManagerWidget::setJobName(QString _id, QString _name) {
JobContainer job;
std::map<QString, JobContainer>::iterator it = processMap_.begin();
// Find item
bool found = false;
for(; it != processMap_.end(); ++it) {
if((*it).first == _id) {
found = true;
job = (*it).second;
break;
}
}
// No such item found -> return
if(!found) return;
(job.id)->setText(_name);
QHash<QString, JobContainer>::iterator it = processMap_.find(_id);
// No such item has been found -> returning
if(it == processMap_.end()) return;
it.value().id->setText(_name);
}
void ProcessManagerWidget::setJobDescription(QString _id, QString _desc) {
JobContainer job;
std::map<QString, JobContainer>::iterator it = processMap_.begin();
// Find item
bool found = false;
for(; it != processMap_.end(); ++it) {
if((*it).first == _id) {
found = true;
job = (*it).second;
break;
}
}
QHash<QString, JobContainer>::iterator it = processMap_.find(_id);
// No such item has been found -> returning
if(!found) return;
if(it == processMap_.end()) return;
// Set new description
(job.description)->setText(_desc);
it.value().description->setText(_desc);
}
void ProcessManagerWidget::addJob(QString _id, QString _description,
int _minSteps, int _maxSteps) {
std::map<QString, JobContainer>::iterator it = processMap_.begin();
// Find item
bool found = false;
for(; it != processMap_.end(); ++it) {
if((*it).first == _id) {
found = true;
break;
}
}
// Item with the same id has already been added
if(found) return;
if(processMap_.contains(_id)) return;
QTableWidgetItem* name = new QTableWidgetItem(_id);
QTableWidgetItem* desc = new QTableWidgetItem(_description);
......@@ -162,7 +118,7 @@ void ProcessManagerWidget::addJob(QString _id, QString _description,
job.progress = progressBar;
job.button = button;
processMap_.insert(std::pair<QString, JobContainer>(_id, job));
processMap_.insert(_id, job);
}
void ProcessManagerWidget::cancelButtonPressed() {
......@@ -180,24 +136,13 @@ void ProcessManagerWidget::cancelButtonPressed() {
void ProcessManagerWidget::removeJob(QString _id) {
JobContainer job;
std::map<QString, JobContainer>::iterator it = processMap_.begin();
// Find item
bool found = false;
for(; it != processMap_.end(); ++it) {
if((*it).first == _id) {
found = true;
job = (*it).second;
break;
}
}
QHash<QString, JobContainer>::iterator it = processMap_.find(_id);
// No such item has been found -> returning
if(!found) return;
if(it == processMap_.end()) return;
this->processList->removeRow(this->processList->row(job.id));
processList->removeRow(processList->row(it.value().id));
// Remove from local map
processMap_.erase(_id);
processMap_.erase(it);
}
......@@ -124,7 +124,7 @@ class ProcessManagerWidget : public QWidget, public Ui::ProcessManagerWidget
JobCancelButton* button;
};
std::map<QString, JobContainer> processMap_;
QHash<QString, JobContainer> processMap_;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment