19#include "moc_qgsattributetypeloaddialog.cpp" 
   29#include <QTableWidgetItem> 
   47  layerComboBox->setCurrentIndex( -1 );
 
   51  connect( keyComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, [
this]( 
int index ) { createPreview( index ); } );
 
   52  connect( valueComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, [
this]( 
int index ) { createPreview( index ); } );
 
   53  connect( previewButton, &QAbstractButton::pressed, 
this, &QgsAttributeTypeLoadDialog::previewButtonPushed );
 
   54  connect( buttonBox, &QDialogButtonBox::helpRequested, 
this, [] {
 
   55    QgsHelp::openHelp( QStringLiteral( 
"working_with_vector/vector_properties.html#edit-widgets" ) );
 
 
   64void QgsAttributeTypeLoadDialog::previewButtonPushed()
 
   66  createPreview( valueComboBox->currentIndex(), 
true );
 
   69void QgsAttributeTypeLoadDialog::createPreview( 
int fieldIndex, 
bool full )
 
   71  previewTableWidget->clearContents();
 
   73  for ( 
int i = previewTableWidget->rowCount() - 1; i > 0; i-- )
 
   75    previewTableWidget->removeRow( i );
 
   77  if ( layerComboBox->currentIndex() < 0 || fieldIndex < 0 )
 
   82  const int idx = keyComboBox->currentIndex();
 
   83  const int idx2 = valueComboBox->currentIndex();
 
   84  QgsMapLayer *dataLayer = layerComboBox->currentLayer();
 
   85  QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>( dataLayer );
 
   90  attributeList.append( idx );
 
   91  attributeList.append( idx2 );
 
  100    const QVariant val2 = f.
attribute( idx2 );
 
  104      valueMap.insert( val1.toString(), val2.toString() );
 
  110  for ( QMap<QString, QVariant>::iterator mit = 
valueMap.begin(); mit != 
valueMap.end(); ++mit, row++ )
 
  112    previewTableWidget->insertRow( row );
 
  113    previewTableWidget->setItem( row, 0, 
new QTableWidgetItem( mit.value().toString() ) );
 
  114    previewTableWidget->setItem( row, 1, 
new QTableWidgetItem( mit.key() ) );
 
  125  return nullCheckBox->isChecked();
 
 
  128void QgsAttributeTypeLoadDialog::loadDataToValueMap()
 
  131  const int idx = keyComboBox->currentIndex();
 
  132  const int idx2 = valueComboBox->currentIndex();
 
  133  QgsMapLayer *dataLayer = layerComboBox->currentLayer();
 
  134  QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>( dataLayer );
 
  139  attributeList.append( idx );
 
  140  attributeList.append( idx2 );
 
  150      mValueMap.insert( f.
attribute( idx2 ).toString(), val );
 
  158  loadDataToValueMap();
 
 
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
 
void accept() override
Overloaded accept method which will write the feature field values, then delegate to QDialog::accept(...
 
QgsAttributeTypeLoadDialog(QgsVectorLayer *vl)
 
bool insertNull()
Returns true if the "Add NULL value" checkbox has been checked.
 
QMap< QString, QVariant > & valueMap()
Returns the value map which is currently active.
 
void setVectorLayer(QgsVectorLayer *layer)
Sets predefined vector layer for selection of data.
 
Wrapper for iterator of features from vector data provider or vector layer.
 
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
 
Wraps a request for features to a vector layer (or directly its vector data provider).
 
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
 
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
 
void setLayer(QgsMapLayer *layer)
Sets the layer for which fields are listed in the combobox.
 
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
 
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
 
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
 
Base class for all map layer types.
 
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
 
Represents a vector layer which manages a vector based dataset.
 
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
 
QList< int > QgsAttributeList