QWidget* QgsComposerColumnSourceDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const { Q_UNUSED( option ); Q_UNUSED( index ); QgsFieldExpressionWidget *fieldExpression = new QgsFieldExpressionWidget( parent ); fieldExpression->setLayer( mVectorLayer ); //listen out for field changes connect( fieldExpression, SIGNAL( fieldChanged( QString ) ), this, SLOT( commitAndCloseEditor() ) ); return fieldExpression; }
QWidget *QgsComposerColumnSourceDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { Q_UNUSED( option ); Q_UNUSED( index ); QgsFieldExpressionWidget *fieldExpression = new QgsFieldExpressionWidget( parent ); fieldExpression->setLayer( mVectorLayer ); fieldExpression->registerExpressionContextGenerator( this ); //listen out for field changes connect( fieldExpression, static_cast < void ( QgsFieldExpressionWidget::* )( const QString & ) >( &QgsFieldExpressionWidget::fieldChanged ), this, [ = ] { const_cast< QgsComposerColumnSourceDelegate * >( this )->commitAndCloseEditor(); } ); return fieldExpression; }
QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QList< DataDefinedSymbolEntry >& entries, const QgsVectorLayer* vl, QWidget * parent, Qt::WindowFlags f ) : QDialog( parent, f ) , mVectorLayer( vl ) { setupUi( this ); QgsFields attributeFields; if ( mVectorLayer ) { attributeFields = mVectorLayer->pendingFields(); } int i = 0; QList< DataDefinedSymbolEntry >::const_iterator entryIt = entries.constBegin(); for ( ; entryIt != entries.constEnd(); ++entryIt ) { QTreeWidgetItem* item = new QTreeWidgetItem( mTreeWidget ); //check box QCheckBox* cb = new QCheckBox( entryIt->title, this ); cb->setChecked( !entryIt->initialValue.isEmpty() ); item->setData( 0, Qt::UserRole, entryIt->property ); mTreeWidget->setItemWidget( item, 0, cb ); // expression QgsFieldExpressionWidget* few = new QgsFieldExpressionWidget( this ); few->setMaximumWidth( 350 ); few->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ); few->setLayer( const_cast<QgsVectorLayer*>( vl ) ); few->setField( entryIt->initialValue ); mTreeWidget->setItemWidget( item, 1, few ); //help text item->setText( 2, entryIt->helpText ); mTreeWidget->addTopLevelItem( item ); ++i; } for ( int c = 0; c != mTreeWidget->columnCount() - 1; c++ ) mTreeWidget->resizeColumnToContents( c ); QSettings settings; restoreGeometry( settings.value( "/Windows/QgsDataDefinedSymbolDialog/geometry" ).toByteArray() ); }