-- pre fy

This commit is contained in:
2025-09-07 16:22:42 +02:00
parent 3ac129ef26
commit 93ec52933e

View File

@@ -253,29 +253,29 @@ void XQItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) co
switch( edType ) switch( edType )
{ {
case XQItemType::ComboBoxType : case XQItemType::ComboBoxType :
{
QComboBox* comboBox = qobject_cast<QComboBox*>(editor);
comboBox->setModel( item.fixedChoices());
comboBox->setCurrentText( item.data().toString() );
comboBox->showPopup();
return;
}
default:
// wir benutzen hier die DisplayRole wenn der Inhalt schon formatiert ist.
int role = item.renderStyle() == XQItem::FormattedStyle ? Qt::DisplayRole : Qt::EditRole;
QVariant value = index.data(role);
QByteArray userProp = editor->metaObject()->userProperty().name();
if (!userProp.isEmpty())
{ {
if (!value.isValid()) QComboBox* comboBox = qobject_cast<QComboBox*>(editor);
value = QVariant(editor->property(userProp).metaType()); comboBox->setModel( item.fixedChoices());
editor->setProperty(userProp, value); comboBox->setCurrentText( item.data().toString() );
comboBox->showPopup();
return;
} }
default:
// wir benutzen hier die DisplayRole wenn der Inhalt schon formatiert ist.
int role = item.renderStyle() == XQItem::FormattedStyle ? Qt::DisplayRole : Qt::EditRole;
QVariant value = index.data(role);
QByteArray userProp = editor->metaObject()->userProperty().name();
if (!userProp.isEmpty())
{
if (!value.isValid())
value = QVariant(editor->property(userProp).metaType());
editor->setProperty(userProp, value);
}
} }
} }