22#include <QStandardItemModel> 
   36QgsProcessingDxfLayerDetailsWidget::QgsProcessingDxfLayerDetailsWidget( 
const QVariant &value, 
QgsProject *project )
 
   40  mFieldsComboBox->setAllowEmptyFieldName( 
true );
 
   42  mContext.setProject( project );
 
   45  mLayer = layer.
layer();
 
   50  mFieldsComboBox->setLayer( mLayer );
 
   60    mGroupBoxBlocks->setVisible( 
true );
 
   66    mGroupBoxBlocks->setVisible( 
false );
 
   75QVariant QgsProcessingDxfLayerDetailsWidget::value()
 const 
   77  const int index = mLayer->fields().lookupField( mFieldsComboBox->currentField() );
 
   78  const QgsDxfExport::DxfLayer layer( mLayer, index, mGroupBoxBlocks->isChecked(), mSpinBoxBlocks->value(), mOverriddenName->text().trimmed() );
 
   87QgsProcessingDxfLayersPanelWidget::QgsProcessingDxfLayersPanelWidget(
 
   88  const QVariant &value,
 
   91  : QgsProcessingMultipleSelectionPanelWidget( QVariantList(), QVariantList(), parent )
 
   94  connect( listView(), &QListView::doubleClicked, 
this, &QgsProcessingDxfLayersPanelWidget::configureLayer );
 
   96  QPushButton *configureLayerButton = 
new QPushButton( tr( 
"Configure Layer…" ) );
 
   97  connect( configureLayerButton, &QPushButton::clicked, 
this, &QgsProcessingDxfLayersPanelWidget::configureLayer );
 
   98  buttonBox()->addButton( configureLayerButton, QDialogButtonBox::ActionRole );
 
  101  mContext.setProject( project );
 
  103  QSet<const QgsVectorLayer *> seenVectorLayers;
 
  104  const QVariantList valueList = value.toList();
 
  105  for ( 
const QVariant &v : valueList )
 
  108    if ( !layer.
layer() )
 
  111    addOption( v, titleForLayer( layer ), 
true );
 
  112    seenVectorLayers.insert( layer.
layer() );
 
  118    if ( seenVectorLayers.contains( layer ) )
 
  122    vm[
"layer"] = layer->id();
 
  123    vm[
"attributeIndex"] = -1;
 
  124    vm[
"overriddenLayerName"] = QString();
 
  125    vm[
"buildDataDefinedBlocks"] = DEFAULT_DXF_DATA_DEFINED_BLOCKS;
 
  126    vm[
"dataDefinedBlocksMaximumNumberOfClasses"] = -1;
 
  128    const QString title = layer->name();
 
  129    addOption( vm, title, 
false );
 
  133void QgsProcessingDxfLayersPanelWidget::configureLayer()
 
  135  const QModelIndexList selection = listView()->selectionModel()->selectedIndexes();
 
  136  if ( selection.size() != 1 )
 
  138    QMessageBox::warning( 
this, tr( 
"Configure Layer" ), tr( 
"Please select a single layer." ) );
 
  142  QStandardItem *item = mModel->itemFromIndex( selection[0] );
 
  143  const QVariant value = item->data( Qt::UserRole );
 
  148    QgsProcessingDxfLayerDetailsWidget *widget = 
new QgsProcessingDxfLayerDetailsWidget( value, mProject );
 
  149    widget->setPanelTitle( tr( 
"Configure Layer" ) );
 
  150    widget->buttonBox()->hide();
 
  152    connect( widget, &QgsProcessingDxfLayerDetailsWidget::widgetChanged, 
this, [ = ]()
 
  154      setItemValue( item, widget->value() );
 
  161    dlg.setWindowTitle( tr( 
"Configure Layer" ) );
 
  162    QVBoxLayout *vLayout = 
new QVBoxLayout();
 
  163    QgsProcessingDxfLayerDetailsWidget *widget = 
new QgsProcessingDxfLayerDetailsWidget( value, mProject );
 
  164    vLayout->addWidget( widget );
 
  165    connect( widget->buttonBox(), &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
 
  166    connect( widget->buttonBox(), &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
 
  167    dlg.setLayout( vLayout );
 
  170      setItemValue( item, widget->value() );
 
  175void QgsProcessingDxfLayersPanelWidget::setItemValue( QStandardItem *item, 
const QVariant &value )
 
  177  mContext.setProject( mProject );
 
  181  item->setText( titleForLayer( layer ) );
 
  182  item->setData( value, Qt::UserRole );
 
  199      title += tr( 
" [overridden name: %1]" ).arg( layer.
overriddenName() );
 
  211QgsProcessingDxfLayersWidget::QgsProcessingDxfLayersWidget( QWidget *parent )
 
  214  QHBoxLayout *hl = 
new QHBoxLayout();
 
  215  hl->setContentsMargins( 0, 0, 0, 0 );
 
  217  mLineEdit = 
new QLineEdit();
 
  218  mLineEdit->setEnabled( 
false );
 
  219  hl->addWidget( mLineEdit, 1 );
 
  221  mToolButton = 
new QToolButton();
 
  222  mToolButton->setText( QString( QChar( 0x2026 ) ) );
 
  223  hl->addWidget( mToolButton );
 
  229  connect( mToolButton, &QToolButton::clicked, 
this, &QgsProcessingDxfLayersWidget::showDialog );
 
  232void QgsProcessingDxfLayersWidget::setValue( 
const QVariant &value )
 
  234  if ( value.isValid() )
 
  235    mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
 
  243void QgsProcessingDxfLayersWidget::setProject( 
QgsProject *project )
 
  248void QgsProcessingDxfLayersWidget::showDialog()
 
  253    QgsProcessingDxfLayersPanelWidget *widget = 
new QgsProcessingDxfLayersPanelWidget( mValue, mProject );
 
  254    widget->setPanelTitle( tr( 
"Input layers" ) );
 
  255    connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged, 
this, [ = ]()
 
  257      setValue( widget->selectedOptions() );
 
  265    dlg.setWindowTitle( tr( 
"Input layers" ) );
 
  266    QVBoxLayout *vLayout = 
new QVBoxLayout();
 
  267    QgsProcessingDxfLayersPanelWidget *widget = 
new QgsProcessingDxfLayersPanelWidget( mValue, mProject );
 
  268    vLayout->addWidget( widget );
 
  269    widget->buttonBox()->addButton( QDialogButtonBox::Cancel );
 
  270    connect( widget->buttonBox(), &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
 
  271    connect( widget->buttonBox(), &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
 
  272    dlg.setLayout( vLayout );
 
  275      setValue( widget->selectedOptions() );
 
  280void QgsProcessingDxfLayersWidget::updateSummaryText()
 
  282  mLineEdit->setText( tr( 
"%n vector layer(s) selected", 
nullptr, mValue.count() ) );
 
  295QString QgsProcessingDxfLayersWidgetWrapper::parameterType()
 const 
  302  return new QgsProcessingDxfLayersWidgetWrapper( parameter, type );
 
  305QWidget *QgsProcessingDxfLayersWidgetWrapper::createWidget()
 
  307  mPanel = 
new QgsProcessingDxfLayersWidget( 
nullptr );
 
  308  mPanel->setProject( widgetContext().project() );
 
  309  connect( mPanel, &QgsProcessingDxfLayersWidget::changed, 
this, [ = ]
 
  311    emit widgetValueHasChanged( 
this );
 
  321    mPanel->setProject( context.
project() );
 
  325void QgsProcessingDxfLayersWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
  330    mPanel->setValue( value );
 
  334QVariant QgsProcessingDxfLayersWidgetWrapper::widgetValue()
 const 
  336  return mPanel ? mPanel->value() : QVariant();
 
  339QStringList QgsProcessingDxfLayersWidgetWrapper::compatibleParameterTypes()
 const 
  350QStringList QgsProcessingDxfLayersWidgetWrapper::compatibleOutputTypes()
 const 
@ VectorAnyGeometry
Any vector layer with geometry.
 
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
 
Contains information about the context in which a processing algorithm is executed.
 
WidgetType
Types of dialogs which Processing widgets can be created for.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
Base class for the definition of processing parameters.
 
static QVariantMap layerAsVariantMap(const QgsDxfExport::DxfLayer &layer)
Converts a single input layer to QVariant representation (a QVariantMap)
 
static QgsDxfExport::DxfLayer variantMapAsLayer(const QVariantMap &layerVariantMap, QgsProcessingContext &context)
Converts a QVariant value (a QVariantMap) to a single input layer.
 
static QString typeName()
Returns the type name for the parameter class.
 
static QString typeName()
Returns the type name for the parameter class.
 
static QString typeName()
Returns the type name for the parameter class.
 
static QString typeName()
Returns the type name for the parameter class.
 
static QString typeName()
Returns the type name for the parameter class.
 
static QString typeName()
Returns the type name for the parameter class.
 
static QString typeName()
Returns the type name for the parameter class.
 
Contains settings which reflect the context in which a Processing parameter widget is shown,...
 
QgsProject * project() const
Returns the project associated with the widget.
 
static QList< QgsVectorLayer * > compatibleVectorLayers(QgsProject *project, const QList< int > &sourceTypes=QList< int >(), bool sort=true)
Returns a list of vector layers from a project which are compatible with the processing framework.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
Represents a vector layer which manages a vector based data sets.
 
Layers and optional attribute index to split into multiple layers using attribute value as layer name...
 
QString overriddenName() const
Returns the overridden layer name to be used in the exported DXF.
 
bool buildDataDefinedBlocks() const
Flag if data defined point block symbols should be created.
 
QgsVectorLayer * layer() const
Returns the layer.
 
int dataDefinedBlocksMaximumNumberOfClasses() const
Returns the maximum number of data defined symbol classes for which blocks are created.
 
QString splitLayerAttribute() const
If the split layer attribute is set, the vector layer will be split into several dxf layers,...
 
int layerOutputAttributeIndex() const
Returns the attribute index used to split into multiple layers.