예제 #1
0
void QgsComposerShapeWidget::on_mShapeStyleButton_clicked()
{
  if ( !mComposerShape )
  {
    return;
  }

  // use the atlas coverage layer, if any
  QgsVectorLayer* coverageLayer = atlasCoverageLayer();

  QgsFillSymbolV2* newSymbol = dynamic_cast<QgsFillSymbolV2*>( mComposerShape->shapeStyleSymbol()->clone() );
  QgsSymbolV2SelectorDialog d( newSymbol, QgsStyleV2::defaultStyle(), coverageLayer, this );

  if ( d.exec() == QDialog::Accepted )
  {
    mComposerShape->beginCommand( tr( "Shape style changed" ) );
    mComposerShape->setShapeStyleSymbol( newSymbol );
    updateShapeStyle();
    mComposerShape->endCommand();
  }
  else
  {
    delete newSymbol;
  }
}
예제 #2
0
void QgsComposerPolygonWidget::on_mPolygonStyleButton_clicked()
{
  if ( !mComposerPolygon )
  {
    return;
  }

  // use the atlas coverage layer, if any
  QgsVectorLayer* coverageLayer = atlasCoverageLayer();

  QScopedPointer<QgsFillSymbol> newSymbol;
  newSymbol.reset( mComposerPolygon->polygonStyleSymbol()->clone() );

  QgsExpressionContext context = mComposerPolygon->createExpressionContext();
  QgsSymbolSelectorDialog d( newSymbol.data(), QgsStyle::defaultStyle(),
                             coverageLayer, this );
  QgsSymbolWidgetContext symbolContext;
  symbolContext.setExpressionContext( &context );
  d.setContext( symbolContext );

  if ( d.exec() == QDialog::Accepted )
  {
    mComposerPolygon->beginCommand( tr( "Polygon style changed" ) );
    mComposerPolygon->setPolygonStyleSymbol( newSymbol.data() );
    updatePolygonStyle();
    mComposerPolygon->endCommand();
  }
}
예제 #3
0
void QgsComposerLabelWidget::on_mInsertExpressionButton_clicked()
{
  if ( !mComposerLabel )
  {
    return;
  }

  QString selText = mTextEdit->textCursor().selectedText();

  // edit the selected expression if there's one
  if ( selText.startsWith( "[%" ) && selText.endsWith( "%]" ) )
    selText = selText.mid( 2, selText.size() - 4 );

  // use the atlas coverage layer, if any
  QgsVectorLayer* coverageLayer = atlasCoverageLayer();
  QgsExpressionBuilderDialog exprDlg( coverageLayer, selText, this );
  exprDlg.setWindowTitle( tr( "Insert expression" ) );
  if ( exprDlg.exec() == QDialog::Accepted )
  {
    QString expression =  exprDlg.expressionText();
    if ( !expression.isEmpty() )
    {
      mComposerLabel->beginCommand( tr( "Insert expression" ) );
      mTextEdit->insertPlainText( "[%" + expression + "%]" );
      mComposerLabel->endCommand();
    }
  }
}
예제 #4
0
void QgsComposerShapeWidget::on_mShapeStyleButton_clicked()
{
  if ( !mComposerShape )
  {
    return;
  }

  // use the atlas coverage layer, if any
  QgsVectorLayer* coverageLayer = atlasCoverageLayer();

  QgsFillSymbol* newSymbol = mComposerShape->shapeStyleSymbol()->clone();
  QgsExpressionContext context = mComposerShape->createExpressionContext();
  QgsSymbolSelectorDialog d( newSymbol, QgsStyle::defaultStyle(), coverageLayer, this );
  QgsSymbolWidgetContext symbolContext;
  symbolContext.setExpressionContext( &context );
  d.setContext( symbolContext );

  if ( d.exec() == QDialog::Accepted )
  {
    mComposerShape->beginCommand( tr( "Shape style changed" ) );
    mComposerShape->setShapeStyleSymbol( newSymbol );
    updateShapeStyle();
    mComposerShape->endCommand();
  }
  delete newSymbol;
}
예제 #5
0
void QgsLayoutLabelWidget::mInsertExpressionButton_clicked()
{
  if ( !mLabel )
  {
    return;
  }

  QString selText = mTextEdit->textCursor().selectedText();

  // edit the selected expression if there's one
  if ( selText.startsWith( QLatin1String( "[%" ) ) && selText.endsWith( QLatin1String( "%]" ) ) )
    selText = selText.mid( 2, selText.size() - 4 );

  // use the atlas coverage layer, if any
#if 0 //TODO
  QgsVectorLayer *coverageLayer = atlasCoverageLayer();
#endif
  QgsVectorLayer *coverageLayer = nullptr;

  QgsExpressionContext context = mLabel->createExpressionContext();
  QgsExpressionBuilderDialog exprDlg( coverageLayer, selText, this, QStringLiteral( "generic" ), context );

  exprDlg.setWindowTitle( tr( "Insert Expression" ) );
  if ( exprDlg.exec() == QDialog::Accepted )
  {
    QString expression = exprDlg.expressionText();
    if ( !expression.isEmpty() )
    {
      mLabel->beginCommand( tr( "Insert expression" ) );
      mTextEdit->insertPlainText( "[%" + expression + "%]" );
      mLabel->endCommand();
    }
  }
}
예제 #6
0
void QgsComposerItemWidget::populateDataDefinedButtons()
{
  QgsVectorLayer* vl = atlasCoverageLayer();

  Q_FOREACH ( QgsDataDefinedButton* button, findChildren< QgsDataDefinedButton* >() )
  {
    button->blockSignals( true );
    button->registerGetExpressionContextCallback( &_getExpressionContext, mItem );
  }
예제 #7
0
void QgsComposerHtmlWidget::on_mInsertExpressionButton_clicked()
{
  if ( !mHtml )
  {
    return;
  }

  int line = 0;
  int index = 0;
  QString selText;
  if ( mHtmlEditor->hasSelectedText() )
  {
    selText = mHtmlEditor->selectedText();

    // edit the selected expression if there's one
    if ( selText.startsWith( "[%" ) && selText.endsWith( "%]" ) )
      selText = selText.mid( 2, selText.size() - 4 );
  }
  else
  {
    mHtmlEditor->getCursorPosition( &line, &index );
  }

  // use the atlas coverage layer, if any
  QgsVectorLayer* coverageLayer = atlasCoverageLayer();
  QScopedPointer<QgsExpressionContext> context( mHtml->createExpressionContext() );
  QgsExpressionBuilderDialog exprDlg( coverageLayer, selText, this, "generic", *context );
  exprDlg.setWindowTitle( tr( "Insert expression" ) );
  if ( exprDlg.exec() == QDialog::Accepted )
  {
    QString expression =  exprDlg.expressionText();
    QgsComposition* composition = mHtml->composition();
    if ( !expression.isEmpty() && composition )
    {
      blockSignals( true );
      composition->beginMultiFrameCommand( mHtml, tr( "HTML source changed" ) );
      if ( mHtmlEditor->hasSelectedText() )
      {
        mHtmlEditor->replaceSelectedText( "[%" + expression + "%]" );
      }
      else
      {
        mHtmlEditor->insertAt( "[%" + expression + "%]", line, index );
      }
      composition->endMultiFrameCommand();
      blockSignals( false );
    }
  }

}
예제 #8
0
void QgsComposerHtmlWidget::populateDataDefinedButtons()
{
  QgsVectorLayer* vl = atlasCoverageLayer();

  //block signals from data defined buttons
  mUrlDDBtn->blockSignals( true );

  //initialise buttons to use atlas coverage layer
  mUrlDDBtn->init( vl, mHtml->dataDefinedProperty( QgsComposerItem::SourceUrl ),
                   QgsDataDefinedButton::AnyType, tr( "url string" ) );

  //initial state of controls - disable related controls when dd buttons are active
  mUrlLineEdit->setEnabled( !mUrlDDBtn->isActive() );

  //unblock signals from data defined buttons
  mUrlDDBtn->blockSignals( false );
}
예제 #9
0
void QgsComposerPictureWidget::populateDataDefinedButtons()
{
  QgsVectorLayer* vl = atlasCoverageLayer();

  //block signals from data defined buttons
  mSourceDDBtn->blockSignals( true );

  //initialise buttons to use atlas coverage layer
  mSourceDDBtn->init( vl, mPicture->dataDefinedProperty( QgsComposerObject::PictureSource ),
                      QgsDataDefinedButton::AnyType, QgsDataDefinedButton::anyStringDesc() );

  //initial state of controls - disable related controls when dd buttons are active
  mPictureLineEdit->setEnabled( !mSourceDDBtn->isActive() );

  //unblock signals from data defined buttons
  mSourceDDBtn->blockSignals( false );
}
void QgsComposerAttributeTableWidget::updateRelationsCombo()
{
  mRelationsComboBox->blockSignals( true );
  mRelationsComboBox->clear();

  QgsVectorLayer* atlasLayer = atlasCoverageLayer();
  if ( atlasLayer )
  {
    QList<QgsRelation> relations = QgsProject::instance()->relationManager()->referencedRelations( atlasLayer );
    Q_FOREACH ( const QgsRelation& relation, relations )
    {
      mRelationsComboBox->addItem( relation.name(), relation.id() );
    }
    if ( mComposerTable )
    {
      mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mComposerTable->relationId() ) );
    }
  }
예제 #11
0
void QgsComposerItemWidget::populateDataDefinedButtons()
{
  QgsVectorLayer* vl = atlasCoverageLayer();

  //block signals from data defined buttons
  mXPositionDDBtn->blockSignals( true );
  mYPositionDDBtn->blockSignals( true );
  mWidthDDBtn->blockSignals( true );
  mHeightDDBtn->blockSignals( true );
  mItemRotationDDBtn->blockSignals( true );
  mTransparencyDDBtn->blockSignals( true );
  mBlendModeDDBtn->blockSignals( true );
  mExcludePrintsDDBtn->blockSignals( true );

  //initialise buttons to use atlas coverage layer
  mXPositionDDBtn->init( vl, mItem->dataDefinedProperty( QgsComposerObject::PositionX ),
                         QgsDataDefinedButton::AnyType, QgsDataDefinedButton::doubleDesc() );
  mYPositionDDBtn->init( vl, mItem->dataDefinedProperty( QgsComposerObject::PositionY ),
                         QgsDataDefinedButton::AnyType, QgsDataDefinedButton::doubleDesc() );
  mWidthDDBtn->init( vl, mItem->dataDefinedProperty( QgsComposerObject::ItemWidth ),
                     QgsDataDefinedButton::AnyType, QgsDataDefinedButton::doubleDesc() );
  mHeightDDBtn->init( vl, mItem->dataDefinedProperty( QgsComposerObject::ItemHeight ),
                      QgsDataDefinedButton::AnyType, QgsDataDefinedButton::doubleDesc() );
  mItemRotationDDBtn->init( vl, mItem->dataDefinedProperty( QgsComposerObject::ItemRotation ),
                            QgsDataDefinedButton::AnyType, QgsDataDefinedButton::double180RotDesc() );
  mTransparencyDDBtn->init( vl, mItem->dataDefinedProperty( QgsComposerObject::Transparency ),
                            QgsDataDefinedButton::AnyType, QgsDataDefinedButton::intTranspDesc() );
  mBlendModeDDBtn->init( vl, mItem->dataDefinedProperty( QgsComposerObject::BlendMode ),
                         QgsDataDefinedButton::String, QgsDataDefinedButton::blendModesDesc() );
  mExcludePrintsDDBtn->init( vl, mItem->dataDefinedProperty( QgsComposerObject::ExcludeFromExports ),
                             QgsDataDefinedButton::String, QgsDataDefinedButton::boolDesc() );

  //unblock signals from data defined buttons
  mXPositionDDBtn->blockSignals( false );
  mYPositionDDBtn->blockSignals( false );
  mWidthDDBtn->blockSignals( false );
  mHeightDDBtn->blockSignals( false );
  mItemRotationDDBtn->blockSignals( false );
  mTransparencyDDBtn->blockSignals( false );
  mBlendModeDDBtn->blockSignals( false );
  mExcludePrintsDDBtn->blockSignals( false );
}
예제 #12
0
void QgsComposerArrowWidget::mLineStyleButton_clicked()
{
  if ( !mArrow )
  {
    return;
  }

  // use the atlas coverage layer, if any
  QgsVectorLayer *coverageLayer = atlasCoverageLayer();

  QgsLineSymbol *newSymbol = mArrow->lineSymbol()->clone();
  QgsExpressionContext context = mArrow->createExpressionContext();

  QgsSymbolSelectorWidget *d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
  QgsSymbolWidgetContext symbolContext;
  symbolContext.setExpressionContext( &context );
  d->setContext( symbolContext );

  connect( d, &QgsPanelWidget::widgetChanged, this, &QgsComposerArrowWidget::updateLineStyleFromWidget );
  connect( d, &QgsPanelWidget::panelAccepted, this, &QgsComposerArrowWidget::cleanUpLineStyleSelector );
  openPanel( d );
  mArrow->beginCommand( tr( "Arrow line style changed" ) );
}
예제 #13
0
void QgsComposerPolygonWidget::on_mPolygonStyleButton_clicked()
{
  if ( !mComposerPolygon )
  {
    return;
  }

  // use the atlas coverage layer, if any
  QgsVectorLayer* coverageLayer = atlasCoverageLayer();

  QgsFillSymbol* newSymbol = mComposerPolygon->polygonStyleSymbol()->clone();
  QgsExpressionContext context = mComposerPolygon->createExpressionContext();

  QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
  QgsSymbolWidgetContext symbolContext;
  symbolContext.setExpressionContext( &context );
  d->setContext( symbolContext );

  connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateStyleFromWidget() ) );
  connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpStyleSelector( QgsPanelWidget* ) ) );
  openPanel( d );
  mComposerPolygon->beginCommand( tr( "Polygon style changed" ) );
}
예제 #14
0
void QgsComposerMapGridWidget::on_mGridMarkerStyleButton_clicked()
{
  if ( !mComposerMapGrid || !mComposerMap )
  {
    return;
  }

  // use the atlas coverage layer, if any
  QgsVectorLayer* coverageLayer = atlasCoverageLayer();

  QgsMarkerSymbol* newSymbol = static_cast<QgsMarkerSymbol*>( mComposerMapGrid->markerSymbol()->clone() );
  QgsExpressionContext context = mComposerMap->createExpressionContext();

  QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
  QgsSymbolWidgetContext symbolContext;
  symbolContext.setExpressionContext( &context );
  d->setContext( symbolContext );

  connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateGridMarkerStyleFromWidget() ) );
  connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpGridMarkerStyleSelector( QgsPanelWidget* ) ) );
  openPanel( d );
  mComposerMap->beginCommand( tr( "Grid markers style changed" ) );
}