| 44 | } |
| 45 | |
| 46 | void IPProcessPropertiesWidget::init(IPProcessStep* processStep) |
| 47 | { |
| 48 | _processStep = processStep; |
| 49 | |
| 50 | // remove all children |
| 51 | while (layout()->count() > 0) |
| 52 | { |
| 53 | QLayoutItem* item = layout()->takeAt(0); |
| 54 | if(item != NULL ) |
| 55 | { |
| 56 | delete item->widget(); |
| 57 | delete item; |
| 58 | } |
| 59 | } |
| 60 | // delete layout(); |
| 61 | |
| 62 | auto* processSettings = _processStep->process()->properties(); |
| 63 | |
| 64 | if(processSettings->size() == 0) |
| 65 | { |
| 66 | addPropertyWidget("This step has no properties.", "", NULL); |
| 67 | } |
| 68 | |
| 69 | // sort the properties by user set position |
| 70 | std::vector<IPLProcessProperty*> orderedProperties; |
| 71 | orderedProperties.reserve(processSettings->size()); |
| 72 | |
| 73 | for (auto &entry: *processSettings) |
| 74 | orderedProperties.push_back(entry.second.get()); |
| 75 | |
| 76 | std::sort(orderedProperties.begin(), orderedProperties.end(), IPProcessPropertiesWidget::sortByPosition); |
| 77 | |
| 78 | // create all property widgets |
| 79 | for (auto &property: orderedProperties) |
| 80 | { |
| 81 | // generate GUI based on the property type |
| 82 | |
| 83 | if (property->widget() == IPL_WIDGET_HIDDEN) {} //Don't process hidden widgets |
| 84 | else if (property->widget() == IPL_WIDGET_LABEL) //Labels are type independent |
| 85 | { |
| 86 | QFormLayout* layout = (QFormLayout*) this->layout(); |
| 87 | |
| 88 | QLabel* lblDescription = new QLabel(property->description()); |
| 89 | lblDescription->setWordWrap(true); |
| 90 | lblDescription->setStyleSheet("color: #666; font-size: 10px"); |
| 91 | layout->addRow("", lblDescription); |
| 92 | |
| 93 | // add widget to list |
| 94 | //_propertyWidgets.append(lblDescription); |
| 95 | } |
| 96 | |
| 97 | else if (auto p = dynamic_cast<IPLProcessPropertyInt*>(property)) |
| 98 | { |
| 99 | IPPropertyWidget *widget = NULL; |
| 100 | QString rawName, name; |
| 101 | switch(p->widget()) |
| 102 | { |
| 103 | case IPL_WIDGET_SLIDER: |
nothing calls this directly
no test coverage detected