| 227 | } |
| 228 | |
| 229 | void ParamEditorDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const |
| 230 | { |
| 231 | // only set model data for first column (value column) |
| 232 | if (index.column() != 1) |
| 233 | { |
| 234 | return; |
| 235 | } |
| 236 | QVariant present_value = index.data(Qt::DisplayRole); |
| 237 | QVariant new_value; |
| 238 | //extract new value |
| 239 | if (qobject_cast<QComboBox *>(editor)) //Drop-down list for enums |
| 240 | { |
| 241 | new_value = QVariant(static_cast<QComboBox *>(editor)->currentText()); |
| 242 | } |
| 243 | else if (qobject_cast<QLineEdit *>(editor)) |
| 244 | { |
| 245 | QString dtype = index.sibling(index.row(), 2).data(Qt::DisplayRole).toString(); |
| 246 | if (dtype == "output file" || dtype == "input file") // input/outut file |
| 247 | { |
| 248 | |
| 249 | new_value = QVariant(static_cast<QLineEdit *>(editor)->text()); |
| 250 | fileName_ = "\0"; |
| 251 | } |
| 252 | else if (static_cast<QLineEdit *>(editor)->text() == "" && ((dtype == "int") || (dtype == "float"))) //numeric |
| 253 | { |
| 254 | if (dtype == "int") |
| 255 | { |
| 256 | new_value = QVariant("0"); |
| 257 | } |
| 258 | else if (dtype == "float") |
| 259 | { |
| 260 | new_value = QVariant("nan"); |
| 261 | } |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | new_value = QVariant(static_cast<QLineEdit *>(editor)->text()); |
| 266 | } |
| 267 | } |
| 268 | else if (qobject_cast<ListEditor*>(editor)) |
| 269 | { |
| 270 | new_value = QString("[%1]").arg(ListUtils::concatenate(static_cast<ListEditor *>(editor)->getList(), ",\n").toQString()); |
| 271 | } |
| 272 | else if (qobject_cast<ListFilterDialog*>(editor)) |
| 273 | { |
| 274 | new_value = QString("[%1]").arg(static_cast<ListFilterDialog*>(editor)->getChosenItems().join(",\n")); |
| 275 | } |
| 276 | else |
| 277 | { |
| 278 | // some new editor ... |
| 279 | } |
| 280 | |
| 281 | // check if it matches the restrictions or is empty |
| 282 | if (new_value.toString() != "") |
| 283 | { |
| 284 | QString type = index.sibling(index.row(), 2).data(Qt::DisplayRole).toString(); |
| 285 | bool restrictions_met = true; |
| 286 | String restrictions = index.sibling(index.row(), 2).data(Qt::UserRole).toString(); |
nothing calls this directly
no test coverage detected