void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked()
{
  QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
  QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mAtlasCoverageLayerComboBox->currentLayer() );

  if ( !atlasMap || !vl )
  {
    return;
  }

  QScopedPointer<QgsExpressionContext> context( mComposition->createExpressionContext() );
  QgsExpressionBuilderDialog exprDlg( vl, mAtlasFeatureFilterEdit->text(), this, "generic", *context );
  exprDlg.setWindowTitle( tr( "Expression based filter" ) );

  if ( exprDlg.exec() == QDialog::Accepted )
  {
    QString expression =  exprDlg.expressionText();
    if ( !expression.isEmpty() )
    {
      mAtlasFeatureFilterEdit->setText( expression );
      atlasMap->setFeatureFilter( mAtlasFeatureFilterEdit->text() );
      updateAtlasFeatures();
    }
  }
}
void QgsAtlasCompositionWidget::on_mApplyConfigButton_clicked()
{
  QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
  if ( !atlasMap )
  {
    return;
  }

  QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mAtlasCoverageLayerComboBox->currentLayer() );
  if ( !vl )
  {
    atlasMap->setCoverageLayer( 0 );
  }
  else
  {
    atlasMap->setCoverageLayer( vl );
  }

  atlasMap->setSortFeatures( mAtlasSortFeatureCheckBox->isChecked() );
  atlasMap->setSortKeyAttributeName( mAtlasSortFeatureKeyComboBox->currentField() );
  Qt::ArrowType at = mAtlasSortFeatureDirectionButton->arrowType();
  at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
  atlasMap->setSortAscending( at == Qt::UpArrow );
  atlasMap->setFilterFeatures( mAtlasFeatureFilterCheckBox->isChecked() );
  atlasMap->setFeatureFilter( mAtlasFeatureFilterEdit->text() );
  atlasMap->setPageNameExpression( mPageNameWidget->currentField() );
  atlasMap->setHideCoverage( mAtlasHideCoverageCheckBox->isChecked() );

  updateAtlasFeatures();
}
Пример #3
0
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_editingFinished()
{
  QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
  if ( !atlasMap )
  {
    return;
  }

  atlasMap->setFeatureFilter( mAtlasFeatureFilterEdit->text() );
  updateAtlasFeatures();
}
Пример #4
0
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked()
{
  QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
  if ( !atlasMap || !atlasMap->coverageLayer() )
  {
    return;
  }

  QgsExpressionBuilderDialog exprDlg( atlasMap->coverageLayer(), mAtlasFeatureFilterEdit->text(), this );
  exprDlg.setWindowTitle( tr( "Expression based filter" ) );
  if ( exprDlg.exec() == QDialog::Accepted )
  {
    QString expression =  exprDlg.expressionText();
    if ( !expression.isEmpty() )
    {
      mAtlasFeatureFilterEdit->setText( expression );
      atlasMap->setFeatureFilter( mAtlasFeatureFilterEdit->text() );
      updateAtlasFeatures();
    }
  }
}