19 #include <QStringList>
22 #include <QFileDialog>
36 m_Types(),
m_DataStorage(
nullptr), m_Predicate(
nullptr), m_TagProperty(
nullptr), m_TagPropertyName()
43 if (index.isValid() ==
false)
44 return QStyledItemDelegate::createEditor(parent, option, index);
46 switch (index.column())
50 return new QLabel(
"", parent);
54 auto c =
new QComboBox(parent);
66 return QStyledItemDelegate::createEditor(parent, option, index);
73 if (index.isValid() ==
false)
76 switch (index.column())
80 QLabel* l = qobject_cast<QLabel*>(editor);
81 if (l->text().isEmpty())
83 QString fileName = index.data().value<QString>();
84 fileName = QFileDialog::getOpenFileName(editor,
"Open SROM file", fileName,
"SROM files (*.rom)");
85 QLabel* l = qobject_cast<QLabel*>(editor);
92 QString type = index.data().value<QString>();
93 QComboBox* c = qobject_cast<QComboBox*>(editor);
94 c->setCurrentIndex(c->findText(type));
95 connect(c, SIGNAL(currentIndexChanged(
int)),
this, SLOT(ComboBoxCurrentIndexChanged(
int)));
104 dsc->setCurrentIndex(dsc->findText(QString::fromStdString(n->GetName())));
105 connect(dsc, SIGNAL(currentIndexChanged(
int)),
this, SLOT(ComboBoxCurrentIndexChanged(
int)));
113 QStyledItemDelegate::setEditorData(editor, index);
120 if (index.isValid() ==
false)
123 switch (index.column())
127 QLabel* l = qobject_cast<QLabel*>(editor);
130 model->setData(index, l->text());
135 QComboBox* c = qobject_cast<QComboBox*>(editor);
137 model->setData(index, c->currentText(), Qt::DisplayRole);
147 model->setData(index, QString::fromStdString(dsc->
GetSelectedNode()->GetName()));
148 if ((m_TagProperty.IsNotNull()) && (m_TagPropertyName.empty() ==
false))
149 dsc->
GetSelectedNode()->SetProperty(m_TagPropertyName.c_str(), m_TagProperty);
157 QStyledItemDelegate::setModelData(editor, model, index);
161 void QmitkNDIToolDelegate::commitAndCloseEditor()
178 void QmitkNDIToolDelegate::ComboBoxCurrentIndexChanged(
int )
180 if(QComboBox *comboBox = qobject_cast<QComboBox *>(sender()))
182 emit commitData(comboBox);
183 emit closeEditor(comboBox);
208 m_TagProperty = prop;
213 m_TagPropertyName = name;
Data management class that handles 'was created by' relations.
Displays all or a subset (defined by a predicate) of nodes of the Data Storage.
mitk::DataStorage::Pointer m_DataStorage
virtual mitk::DataNode::Pointer GetSelectedNode() const
Returns the selected _DataNode or 0 if there is none.