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 ) ) );
46 connect( previewButton, SIGNAL( pressed() ),
this, SLOT( previewButtonPushed() ) );
50 keyComboBox->setDisabled(
true );
51 valueComboBox->setDisabled(
true );
64 void QgsAttributeTypeLoadDialog::previewButtonPushed()
66 createPreview( valueComboBox->currentIndex(), true );
69 void QgsAttributeTypeLoadDialog::fillLayerList()
71 layerComboBox->blockSignals(
true );
72 layerComboBox->clear();
77 layerComboBox->addItem( vl->
name(), vl->
id() );
79 layerComboBox->setCurrentIndex( -1 );
83 void QgsAttributeTypeLoadDialog::fillComboBoxes(
int layerIndex )
85 keyComboBox->blockSignals(
true );
86 valueComboBox->blockSignals(
true );
90 valueComboBox->clear();
97 for ( ; it != fieldMap.
end(); ++it )
99 keyComboBox->addItem( it.
key(), it.
value() );
100 valueComboBox->addItem( it.
key(), it.
value() );
104 keyComboBox->setEnabled(
nullptr != vLayer );
105 valueComboBox->setEnabled(
nullptr != vLayer );
107 keyComboBox->setCurrentIndex( -1 );
108 valueComboBox->setCurrentIndex( -1 );
110 keyComboBox->blockSignals(
false );
111 valueComboBox->blockSignals(
false );
114 void QgsAttributeTypeLoadDialog::createPreview(
int fieldIndex,
bool full )
116 previewTableWidget->clearContents();
118 for (
int i = previewTableWidget->rowCount() - 1; i > 0; i-- )
120 previewTableWidget->removeRow( i );
122 if ( layerComboBox->currentIndex() < 0 || fieldIndex < 0 )
127 int idx = keyComboBox->itemData( keyComboBox->currentIndex() ).toInt();
128 int idx2 = valueComboBox->itemData( valueComboBox->currentIndex() ).toInt();
135 attributeList.
append( idx );
136 attributeList.
append( idx2 );
151 if ( !full && valueMap.
size() > 8 )
157 previewTableWidget->insertRow( row );
158 previewTableWidget->setItem( row, 0,
new QTableWidgetItem( mit.value().toString() ) );
170 return nullCheckBox->isChecked();
173 void QgsAttributeTypeLoadDialog::loadDataToValueMap()
176 int idx = keyComboBox->itemData( keyComboBox->currentIndex() ).toInt();
177 int idx2 = valueComboBox->itemData( valueComboBox->currentIndex() ).toInt();
184 attributeList.
append( idx );
185 attributeList.
append( idx2 );
203 loadDataToValueMap();
Wrapper for iterator of features from vector data provider or vector layer.
Base class for all map layer types.
QString name() const
Get the display name of the layer.
void setVectorLayer(QgsVectorLayer *layer)
Sets predefined vector layer for selection of data.
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...
void accept() override
Overloaded accept method which will write the feature field values, then delegate to QDialog::accept(...
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
QMap< QString, QVariant > & valueMap()
Getter to value map which is currently active.
void append(const T &value)
QgsAttributeTypeLoadDialog(QgsVectorLayer *vl)
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.
bool blockSignals(bool block)
const Key key(const T &value) const
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.
iterator insert(const Key &key, const T &value)
QgsVectorDataProvider * dataProvider()
Returns the data provider.
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
const T value(const Key &key) const