25 #include <QTableWidgetItem>
30 #include <QScrollArea>
33 #include <QPushButton>
34 #include <QHBoxLayout>
35 #include <QFileDialog>
43 connect( layerComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT(
fillComboBoxes(
int ) ) );
44 connect( keyComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT(
createPreview(
int ) ) );
45 connect( valueComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT(
createPreview(
int ) ) );
72 layerComboBox->clear();
77 layerComboBox->addItem( vl->
name(), vl->
id() );
85 valueComboBox->clear();
99 QMap<QString, int>::iterator it = fieldMap.begin();
100 for ( ; it != fieldMap.end(); ++it )
102 keyComboBox->addItem( it.key(), it.value() );
103 valueComboBox->addItem( it.key(), it.value() );
110 previewTableWidget->clearContents();
112 for (
int i = previewTableWidget->rowCount() - 1; i > 0; i-- )
114 previewTableWidget->removeRow( i );
116 if ( layerComboBox->currentIndex() < 0 || fieldIndex < 0 )
121 int idx = keyComboBox->itemData( keyComboBox->currentIndex() ).toInt();
122 int idx2 = valueComboBox->itemData( valueComboBox->currentIndex() ).toInt();
125 if ( vLayer == NULL )
131 attributeList.append( idx );
132 attributeList.append( idx2 );
142 if ( val1.isValid() && !val1.isNull() && !val1.toString().isEmpty()
143 && val2.isValid() && !val2.isNull() && !val2.toString().isEmpty() )
145 valueMap.insert( val1.toString(), val2.toString() );
147 if ( !full && valueMap.size() > 8 )
151 for ( QMap<QString, QVariant>::iterator mit = valueMap.begin(); mit != valueMap.end(); ++mit, row++ )
153 previewTableWidget->insertRow( row );
154 previewTableWidget->setItem( row, 0,
new QTableWidgetItem( mit.value().toString() ) );
155 previewTableWidget->setItem( row, 1,
new QTableWidgetItem( mit.key() ) );
167 return nullCheckBox->isChecked();
173 int idx = keyComboBox->itemData( keyComboBox->currentIndex() ).toInt();
174 int idx2 = valueComboBox->itemData( valueComboBox->currentIndex() ).toInt();
177 if ( vLayer == NULL )
183 attributeList.append( idx );
184 attributeList.append( idx2 );
192 if ( val.isValid() && !val.isNull() && !val.toString().isEmpty() )
Wrapper for iterator of features from vector data provider or vector layer.
Base class for all map layer types.
void fillComboBoxes(int layerIndex)
Slot which reacts to change of selected layer to fill other two comboboxes with correct data...
void setVectorLayer(QgsVectorLayer *layer)
Sets predefined vector layer for selection of data.
QMap< QString, QVariant > mValueMap
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
~QgsAttributeTypeLoadDialog()
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QMap< QString, QVariant > & valueMap()
Getter to value map which is currently active.
const QString & name() const
Get the display name of the layer.
void fillLayerList()
Internal function to fill the list of layers.
QgsAttributeTypeLoadDialog(QgsVectorLayer *vl)
void accept()
Overloaded accept method which will write the feature field values, then delegate to QDialog::accept(...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
bool insertNull()
Returns true if the "Add NULL value" checkbox has been checked.
QList< int > QgsAttributeList
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
QMap< QString, int > fieldNameMap() const
Return a map where the key is the name of the field and the value is its index.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
void loadDataToValueMap()
Function to transfer data from layer to value map used in editing.
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
void previewButtonPushed()
Slot to react to value Preview button pushed.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
void createPreview(int fieldIndex, bool full=false)
Slot to react to button push or change of selected column for display of preview. ...
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Represents a vector layer which manages a vector based data sets.