@@ -136,12 +136,13 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
136
136
if ( !vl )
137
137
return 0 ;
138
138
139
- bool synchronized = false ;
140
139
QWidget *myWidget = 0 ;
141
140
QgsVectorLayer::EditType editType = vl->editType ( idx );
142
141
const QgsField &field = vl->pendingFields ()[idx];
143
142
QVariant::Type myFieldType = field.type ();
144
143
144
+ bool synchronized = false ;
145
+
145
146
switch ( editType )
146
147
{
147
148
case QgsVectorLayer::UniqueValues:
@@ -438,12 +439,14 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
438
439
QLineEdit *le = 0 ;
439
440
QTextEdit *te = 0 ;
440
441
QPlainTextEdit *pte = 0 ;
442
+ QComboBox * cb = 0 ;
441
443
442
444
if ( editor )
443
445
{
444
446
le = qobject_cast<QLineEdit *>( editor );
445
447
te = qobject_cast<QTextEdit *>( editor );
446
448
pte = qobject_cast<QPlainTextEdit *>( editor );
449
+ cb = qobject_cast<QComboBox *>( editor );
447
450
}
448
451
else if ( editType == QgsVectorLayer::TextEdit )
449
452
{
@@ -491,15 +494,42 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
491
494
myWidget = pte;
492
495
}
493
496
497
+ if ( cb )
498
+ {
499
+ myWidget = cb;
500
+ }
501
+
494
502
if ( myWidget )
495
503
{
496
504
myWidget->setDisabled ( editType == QgsVectorLayer::Immutable );
497
505
506
+ QgsStringRelay* relay = NULL ;
507
+
498
508
QMap<int , QWidget*>::const_iterator it = proxyWidgets.find ( idx );
499
509
if ( it != proxyWidgets.end () )
500
510
{
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 ) );
503
533
}
504
534
}
505
535
}
0 commit comments