-- pre-holiday
This commit is contained in:
@@ -220,27 +220,35 @@ QSize XQItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelI
|
||||
}
|
||||
|
||||
|
||||
//! Erzeugt ein editor-widget, sofern ein gültiger content-Ptr vorhanden und ein editor-Type gesetzt ist.
|
||||
|
||||
QWidget* XQItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
|
||||
return QStyledItemDelegate::createEditor( parent, option, index );
|
||||
|
||||
int editorType = XQItem::xqItemFromIndex(index).editorType();
|
||||
QWidget* editor = itemEditorFactory()->createEditor(editorType, parent);
|
||||
if( editor )
|
||||
XQItem& item = xqItemFromIndex(index);
|
||||
XQItem::EditorType edType = item.editorType();
|
||||
if( !item.hasContentNode() || edType == XQItem::NoEditorType )
|
||||
{
|
||||
return editor;
|
||||
qDebug() << "---- NO Content or NO EditorType";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
qDebug() << "---- ed type:" << XQItem::fetchEditorTypeToString( edType ) << ": " << edType;
|
||||
//return QStyledItemDelegate::createEditor( parent, option, index );
|
||||
|
||||
return itemEditorFactory()->createEditor(edType, parent);
|
||||
}
|
||||
|
||||
|
||||
//!
|
||||
void XQItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
|
||||
XQItem& item = xqItemFromIndex( index );
|
||||
switch( item.editorType() )
|
||||
XQItem::EditorType edType = item.editorType();
|
||||
if( edType != XQItem::NoEditorType )
|
||||
{
|
||||
switch( edType )
|
||||
{
|
||||
case XQItemType::ComboBoxType :
|
||||
{
|
||||
QComboBox* comboBox = qobject_cast<QComboBox*>(editor);
|
||||
@@ -251,11 +259,23 @@ void XQItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) co
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
//QStyledItemDelegate::setEditorData(editor, index);
|
||||
// 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QStyledItemDelegate::setEditorData(editor, index);
|
||||
}
|
||||
|
||||
void XQItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
|
Reference in New Issue
Block a user