@@ -88,14 +88,14 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
88
88
89
89
// load Fields
90
90
91
- DnDTreeItemData catItemData = DnDTreeItemData ( DnDTreeItemData::Container, " Fields" );
91
+ DnDTreeItemData catItemData = DnDTreeItemData ( DnDTreeItemData::Container, " Fields" , " Fields " );
92
92
QTreeWidgetItem *catitem = mAvailableWidgetsTree ->addItem ( mAvailableWidgetsTree ->invisibleRootItem (), catItemData );
93
93
94
94
const QgsFields fields = mLayer ->fields ();
95
95
for ( int i = 0 ; i < fields.size (); ++i )
96
96
{
97
97
const QgsField field = fields.at ( i );
98
- DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Field, field.name () );
98
+ DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Field, field.name (), field. name () );
99
99
itemData.setShowLabel ( true );
100
100
101
101
FieldConfig cfg ( mLayer , i );
@@ -108,14 +108,14 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
108
108
catitem->setExpanded ( true );
109
109
110
110
// load Relations
111
- catItemData = DnDTreeItemData ( DnDTreeItemData::Container, " Relations" );
111
+ catItemData = DnDTreeItemData ( DnDTreeItemData::Container, " Relations" , " Relations " );
112
112
catitem = mAvailableWidgetsTree ->addItem ( mAvailableWidgetsTree ->invisibleRootItem (), catItemData );
113
113
114
114
const QList<QgsRelation> relations = QgsProject::instance ()->relationManager ()->referencedRelations ( mLayer );
115
115
116
116
for ( const QgsRelation &relation : relations )
117
117
{
118
- DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Relation, QStringLiteral ( " %1" ).arg ( relation .id () ) );
118
+ DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Relation, QStringLiteral ( " %1" ).arg ( relation .id () ), QStringLiteral ( " %1 " ). arg ( relation . name () ) );
119
119
itemData.setShowLabel ( true );
120
120
121
121
RelationConfig cfg ( mLayer , relation .id () );
@@ -399,7 +399,7 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
399
399
{
400
400
case QgsAttributeEditorElement::AeTypeField:
401
401
{
402
- DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Field, widgetDef->name () );
402
+ DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Field, widgetDef->name (), widgetDef-> name () );
403
403
itemData.setShowLabel ( widgetDef->showLabel () );
404
404
newWidget = tree->addItem ( parent, itemData );
405
405
break ;
@@ -408,7 +408,7 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
408
408
case QgsAttributeEditorElement::AeTypeRelation:
409
409
{
410
410
const QgsAttributeEditorRelation *relationEditor = static_cast <const QgsAttributeEditorRelation *>( widgetDef );
411
- DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Relation, relationEditor->relation ().id ());
411
+ DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Relation, relationEditor->relation ().id (), relationEditor-> relation (). name () );
412
412
itemData.setShowLabel ( widgetDef->showLabel () );
413
413
RelationEditorConfiguration relEdConfig;
414
414
relEdConfig.showLinkButton = relationEditor->showLinkButton ();
@@ -420,7 +420,7 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
420
420
421
421
case QgsAttributeEditorElement::AeTypeContainer:
422
422
{
423
- DnDTreeItemData itemData ( DnDTreeItemData::Container, widgetDef->name () );
423
+ DnDTreeItemData itemData ( DnDTreeItemData::Container, widgetDef->name (), widgetDef-> name () );
424
424
itemData.setShowLabel ( widgetDef->showLabel () );
425
425
426
426
const QgsAttributeEditorContainer *container = static_cast <const QgsAttributeEditorContainer *>( widgetDef );
@@ -771,7 +771,7 @@ QTreeWidgetItem *DnDTree::addContainer( QTreeWidgetItem *parent, const QString &
771
771
QTreeWidgetItem *newItem = new QTreeWidgetItem ( QStringList () << title );
772
772
newItem->setBackground ( 0 , QBrush ( Qt::lightGray ) );
773
773
newItem->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled );
774
- QgsAttributesFormProperties::DnDTreeItemData itemData ( QgsAttributesFormProperties::DnDTreeItemData::Container, title );
774
+ QgsAttributesFormProperties::DnDTreeItemData itemData ( QgsAttributesFormProperties::DnDTreeItemData::Container, title, title );
775
775
itemData.setColumnCount ( columnCount );
776
776
newItem->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, itemData );
777
777
parent->addChild ( newItem );
@@ -811,6 +811,7 @@ QTreeWidgetItem *DnDTree::addItem( QTreeWidgetItem *parent, QgsAttributesFormPro
811
811
}
812
812
}
813
813
newItem->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, data );
814
+ newItem->setText ( 0 , data.displayName () );
814
815
815
816
if ( index < 0 )
816
817
parent->addChild ( newItem );
@@ -1082,19 +1083,21 @@ void DnDTree::setType( const Type &value )
1082
1083
1083
1084
QDataStream &operator <<( QDataStream &stream, const QgsAttributesFormProperties::DnDTreeItemData &data )
1084
1085
{
1085
- stream << ( quint32 )data.type () << data.name ();
1086
+ stream << ( quint32 )data.type () << data.name () << data. displayName () ;
1086
1087
return stream;
1087
1088
}
1088
1089
1089
1090
QDataStream &operator >>( QDataStream &stream, QgsAttributesFormProperties::DnDTreeItemData &data )
1090
1091
{
1091
1092
QString name;
1093
+ QString displayName;
1092
1094
quint32 type;
1093
1095
1094
- stream >> type >> name;
1096
+ stream >> type >> name >> displayName ;
1095
1097
1096
1098
data.setType ( ( QgsAttributesFormProperties::DnDTreeItemData::Type )type );
1097
1099
data.setName ( name );
1100
+ data.setDisplayName ( displayName );
1098
1101
1099
1102
return stream;
1100
1103
}
0 commit comments