@@ -136,12 +136,13 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
136136 if ( !vl )
137137 return 0 ;
138138
139- bool synchronized = false ;
140139 QWidget *myWidget = 0 ;
141140 QgsVectorLayer::EditType editType = vl->editType ( idx );
142141 const QgsField &field = vl->pendingFields ()[idx];
143142 QVariant::Type myFieldType = field.type ();
144143
144+ bool synchronized = false ;
145+
145146 switch ( editType )
146147 {
147148 case QgsVectorLayer::UniqueValues:
@@ -438,12 +439,14 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
438439 QLineEdit *le = 0 ;
439440 QTextEdit *te = 0 ;
440441 QPlainTextEdit *pte = 0 ;
442+ QComboBox * cb = 0 ;
441443
442444 if ( editor )
443445 {
444446 le = qobject_cast<QLineEdit *>( editor );
445447 te = qobject_cast<QTextEdit *>( editor );
446448 pte = qobject_cast<QPlainTextEdit *>( editor );
449+ cb = qobject_cast<QComboBox *>( editor );
447450 }
448451 else if ( editType == QgsVectorLayer::TextEdit )
449452 {
@@ -491,15 +494,42 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
491494 myWidget = pte;
492495 }
493496
497+ if ( cb )
498+ {
499+ myWidget = cb;
500+ }
501+
494502 if ( myWidget )
495503 {
496504 myWidget->setDisabled ( editType == QgsVectorLayer::Immutable );
497505
506+ QgsStringRelay* relay = NULL ;
507+
498508 QMap<int , QWidget*>::const_iterator it = proxyWidgets.find ( idx );
499509 if ( it != proxyWidgets.end () )
500510 {
501- synchronized = connect ( *it, SIGNAL ( textChanged ( QString ) ), myWidget, SLOT ( setText ( QString ) ) );
502- synchronized &= connect ( myWidget, SIGNAL ( textChanged ( QString ) ), *it, SLOT ( setText ( QString ) ) );
511+ QObject* obj = qvariant_cast<QObject*>( (*it)->property ( " QgisAttrEditProxy" ) );
512+ relay = qobject_cast<QgsStringRelay*>( obj );
513+ }
514+ else
515+ {
516+ relay = new QgsStringRelay ( myWidget );
517+ }
518+
519+ if ( cb && cb->isEditable () )
520+ {
521+ synchronized = connect ( relay, SIGNAL ( textChanged ( QString ) ), myWidget, SLOT ( setEditText ( QString ) ) );
522+ synchronized &= connect ( myWidget, SIGNAL ( editTextChanged ( QString ) ), relay, SLOT ( changeText ( QString ) ) );
523+ }
524+ else
525+ {
526+ synchronized = connect ( relay, SIGNAL ( textChanged ( QString ) ), myWidget, SLOT ( setText ( QString ) ) );
527+ synchronized &= connect ( myWidget, SIGNAL ( textChanged ( QString ) ), relay, SLOT ( changeText ( QString ) ) );
528+ }
529+
530+ if ( !cb || cb->isEditable () )
531+ {
532+ myWidget->setProperty ( " QgisAttrEditProxy" , QVariant ( QMetaType::QObjectStar, &relay ) );
503533 }
504534 }
505535 }
0 commit comments