Пример #1
0
void QgsFieldExpressionWidget::setField( const QString &fieldName )
{
  if ( fieldName.isEmpty() )
    return;

  QModelIndex idx = mFieldProxyModel->sourceFieldModel()->indexFromName( fieldName );
  if ( !idx.isValid() )
  {
    // try to remove quotes and white spaces
    QString simpleFieldName = fieldName.trimmed();
    if ( simpleFieldName.startsWith( '"' ) && simpleFieldName.endsWith( '"' ) )
    {
      simpleFieldName.remove( 0, 1 ).chop( 1 );
      idx = mFieldProxyModel->sourceFieldModel()->indexFromName( simpleFieldName );
    }

    if ( !idx.isValid() )
    {
      // new expression
      mFieldProxyModel->sourceFieldModel()->setExpression( fieldName );
      idx = mFieldProxyModel->sourceFieldModel()->indexFromName( fieldName );
    }
  }
  QModelIndex proxyIndex = mFieldProxyModel->mapFromSource( idx );
  mCombo->setCurrentIndex( proxyIndex.row() );
  currentFieldChanged();
}
Пример #2
0
void QgsFieldExpressionWidget::expressionEditingFinished()
{
  const QString expression = mCombo->lineEdit()->text();
  QModelIndex idx = mFieldModel->setExpression( expression );
  mCombo->setCurrentIndex( idx.row() );
  currentFieldChanged();
}
void QgsFieldExpressionWidget::expressionEditingFinished()
{
  const QString expression = mCombo->lineEdit()->text();
  mFieldProxyModel->sourceFieldModel()->setExpression( expression );
  QModelIndex idx = mFieldProxyModel->sourceFieldModel()->indexFromName( expression );
  QModelIndex proxyIndex = mFieldProxyModel->mapFromSource( idx );
  mCombo->setCurrentIndex( proxyIndex.row() );
  currentFieldChanged();
}
Пример #4
0
void QgsFieldExpressionWidget::setField( const QString fieldName )
{
  if ( fieldName.isEmpty() )
    return;

  QModelIndex idx = mFieldModel->indexFromName( fieldName );
  if ( !idx.isValid() )
  {
    // new expression
    idx = mFieldModel->setExpression( fieldName );
  }
  mCombo->setCurrentIndex( idx.row() );

  currentFieldChanged();
}