void QgsAttributeTypeDialog::setEditorWidgetType( const QString &type ) { mWidgetTypeComboBox->setCurrentIndex( mWidgetTypeComboBox->findData( type ) ); if ( mEditorConfigWidgets.contains( type ) ) { stackedWidget->setCurrentWidget( mEditorConfigWidgets[type] ); } else { QgsEditorConfigWidget *cfgWdg = QgsGui::editorWidgetRegistry()->createConfigWidget( type, mLayer, mFieldIdx, this ); if ( cfgWdg ) { cfgWdg->setConfig( mWidgetConfig ); stackedWidget->addWidget( cfgWdg ); stackedWidget->setCurrentWidget( cfgWdg ); mEditorConfigWidgets.insert( type, cfgWdg ); connect( cfgWdg, &QgsEditorConfigWidget::changed, this, &QgsAttributeTypeDialog::defaultExpressionChanged ); } else { QgsDebugMsg( "Oops, couldn't create editor widget config dialog..." ); } } //update default expression preview defaultExpressionChanged(); }
void QgsAttributeTypeDialog::setWidgetV2Type( const QString& type ) { for ( int i = 0; i < selectionListWidget->count(); i++ ) { QListWidgetItem* item = selectionListWidget->item( i ); if ( item->data( Qt::UserRole ).toString() == type ) { selectionListWidget->setCurrentItem( item ); break; } } if ( mEditorConfigWidgets.contains( type ) ) { stackedWidget->setCurrentWidget( mEditorConfigWidgets[type] ); } else { QgsEditorConfigWidget* cfgWdg = QgsEditorWidgetRegistry::instance()->createConfigWidget( type, mLayer, mFieldIdx, this ); if ( cfgWdg ) { cfgWdg->setConfig( mWidgetV2Config ); stackedWidget->addWidget( cfgWdg ); stackedWidget->setCurrentWidget( cfgWdg ); mEditorConfigWidgets.insert( type, cfgWdg ); } else { QgsDebugMsg( "Oops, couldn't create editor widget config dialog..." ); } } }
const QgsEditorWidgetConfig QgsAttributeTypeDialog::editorWidgetConfig() { QListWidgetItem* item = selectionListWidget->currentItem(); if ( item ) { QString widgetType = item->data( Qt::UserRole ).toString(); QgsEditorConfigWidget* cfgWdg = mEditorConfigWidgets[ widgetType ]; if ( cfgWdg ) { return cfgWdg->config(); } } return QgsEditorWidgetConfig(); }
const QVariantMap QgsAttributeTypeDialog::editorWidgetConfig() { QStandardItem *item = currentItem(); if ( item ) { QString widgetType = item->data( Qt::UserRole ).toString(); QgsEditorConfigWidget *cfgWdg = mEditorConfigWidgets[ widgetType ]; if ( cfgWdg ) { return cfgWdg->config(); } } return QVariantMap(); }
void QgsAttributeTypeDialog::setEditorWidgetType( const QString &type ) { for ( int i = 0; i < selectionListWidget->count(); i++ ) { QListWidgetItem *item = selectionListWidget->item( i ); if ( item->data( Qt::UserRole ).toString() == type ) { selectionListWidget->setCurrentItem( item ); break; } } if ( mEditorConfigWidgets.contains( type ) ) { stackedWidget->setCurrentWidget( mEditorConfigWidgets[type] ); } else { QgsEditorConfigWidget *cfgWdg = QgsGui::editorWidgetRegistry()->createConfigWidget( type, mLayer, mFieldIdx, this ); if ( cfgWdg ) { cfgWdg->setConfig( mWidgetConfig ); stackedWidget->addWidget( cfgWdg ); stackedWidget->setCurrentWidget( cfgWdg ); mEditorConfigWidgets.insert( type, cfgWdg ); connect( cfgWdg, &QgsEditorConfigWidget::changed, this, &QgsAttributeTypeDialog::defaultExpressionChanged ); } else { QgsDebugMsg( "Oops, couldn't create editor widget config dialog..." ); } } //update default expression preview defaultExpressionChanged(); }