Ejemplo n.º 1
0
void QgsValueMapWidgetWrapper::initWidget( QWidget* editor )
{
  mComboBox = qobject_cast<QComboBox*>( editor );

  if ( mComboBox )
  {
    const QgsEditorWidgetConfig cfg = config();
    QgsEditorWidgetConfig::ConstIterator it = cfg.constBegin();

    while ( it != cfg.constEnd() )
    {
      mComboBox->addItem( it.key(), it.value() );
      ++it;
    }
    connect( mComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( valueChanged() ) );
  }
}
Ejemplo n.º 2
0
void QgsValueMapWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
{
  Q_UNUSED( layer )
  Q_UNUSED( fieldIdx )

  QgsEditorWidgetConfig::ConstIterator it = config.constBegin();

  while ( it != config.constEnd() )
  {
    QDomElement elem = doc.createElement( "value" );

    elem.setAttribute( "key", it.key() );
    elem.setAttribute( "value", it.value().toString() );

    configElement.appendChild( elem );

    ++it;
  }
}
void QgsValueMapSearchWidgetWrapper::initWidget( QWidget* editor )
{
  mComboBox = qobject_cast<QComboBox*>( editor );

  if ( mComboBox )
  {
    const QgsEditorWidgetConfig cfg = config();
    QgsEditorWidgetConfig::ConstIterator it = cfg.constBegin();
    mComboBox->addItem( tr( "Please select" ), "" );

    while ( it != cfg.constEnd() )
    {
      if ( it.value() != QStringLiteral( VALUEMAP_NULL_TEXT ) )
        mComboBox->addItem( it.key(), it.value() );
      ++it;
    }
    connect( mComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( comboBoxIndexChanged( int ) ) );
  }
}
Ejemplo n.º 4
0
void QgsValueMapConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
{
  tableWidget->clearContents();
  for ( int i = tableWidget->rowCount() - 1; i > 0; i-- )
  {
    tableWidget->removeRow( i );
  }

  int row = 0;
  for ( QgsEditorWidgetConfig::ConstIterator mit = config.begin(); mit != config.end(); mit++, row++ )
  {
    tableWidget->insertRow( row );
    if ( mit.value().isNull() )
    {
      tableWidget->setItem( row, 0, new QTableWidgetItem( mit.key() ) );
    }
    else
    {
      tableWidget->setItem( row, 0, new QTableWidgetItem( mit.value().toString() ) );
      tableWidget->setItem( row, 1, new QTableWidgetItem( mit.key() ) );
    }
  }
}