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

Method createEditor

src/openms_gui/source/VISUAL/ParamEditor.cpp:69–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 }
68
69 QWidget* ParamEditorDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex& index) const
70 {
71 Int type = index.sibling(index.row(), 0).data(Qt::UserRole).toInt();
72
73 // only create editor for first column (value column)
74 if (index.column() != 1 || type == ParamEditor::NODE)
75 {
76 return nullptr;
77 }
78
79 has_uncommited_data_ = false; // by default all data is committed
80
81 QString dtype = index.sibling(index.row(), 2).data(Qt::DisplayRole).toString();
82 QString restrictions = index.sibling(index.row(), 2).data(Qt::UserRole).toString();
83 QString value = index.sibling(index.row(), 1).data(Qt::DisplayRole).toString();
84 if (dtype == "string" && restrictions != "") //Drop-down list for enums
85 {
86 QComboBox* editor = new QComboBox(parent);
87 QStringList list;
88 list.append("");
89 list += restrictions.split(",");
90 editor->addItems(list);
91 connect(editor, SIGNAL(activated(int)), this, SLOT(commitAndCloseEditor_()));
92 return editor;
93 }
94 else if (dtype == "output file")
95 {
96 QLineEdit* editor = new QLineEdit(parent);
97 QString dir = ""; // = index.sibling(index.row(),0).data(Qt::DisplayRole).toString();
98 if (File::isDirectory(value) || File::writable(value))
99 {
100 dir = File::absolutePath(value).toQString();
101 }
102 fileName_ = QFileDialog::getSaveFileName(editor, tr("Output File"), dir);
103 return editor;
104 }
105 else if (dtype == "input file")
106 {
107 QLineEdit* editor = new QLineEdit(parent);
108 QString dir = ""; // = index.sibling(index.row(),0).data(Qt::DisplayRole).toString();
109 if (File::isDirectory(value) || File::exists(value))
110 {
111 dir = File::absolutePath(value).toQString();
112 }
113 fileName_ = QFileDialog::getOpenFileName(editor, tr("Input File"), dir);
114 return editor;
115 }
116 else if (dtype == "string list" && !restrictions.isEmpty())
117 {
118 ListFilterDialog* editor = new ListFilterDialog(nullptr);
119 connect(editor, SIGNAL(accepted()), this, SLOT(commitAndCloseEditor_()));
120 connect(editor, SIGNAL(rejected()), this, SLOT(closeEditor_()));
121 return editor;
122 }
123 else if (dtype == "string list" || dtype == "int list" || dtype == "double list" || dtype == "input file list" || dtype == "output file list") // for lists
124 {
125 QString title = "<" + index.sibling(index.row(), 0).data(Qt::DisplayRole).toString() + "> " + "(<" + dtype + ">)";
126 ListEditor* editor = new ListEditor(nullptr, title);

Callers

nothing calls this directly

Calls 8

toIntMethod · 0.80
rowMethod · 0.80
setTypeNameMethod · 0.80
toStringMethod · 0.45
appendMethod · 0.45
splitMethod · 0.45
toQStringMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected