MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / setModelData

Method setModelData

src/openms_gui/source/VISUAL/ParamEditor.cpp:229–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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();

Callers

nothing calls this directly

Calls 12

concatenateFunction · 0.85
rowMethod · 0.80
getListMethod · 0.80
getChosenItemsMethod · 0.80
toIntMethod · 0.80
toDoubleMethod · 0.80
QStringClass · 0.50
toStringMethod · 0.45
toQStringMethod · 0.45
splitMethod · 0.45
emptyMethod · 0.45
setDataMethod · 0.45

Tested by

no test coverage detected