Skip to content
Permalink
Browse files

Don't list join fields to facilitate 'save as' function (fixes #3857)…

…. Don't display the query builder if a layer has joins (#3858)
  • Loading branch information
Marco Hugentobler authored and mhugent committed Jun 10, 2011
1 parent dac39eb commit db20ac280841e2c908c42e5513f55d7b535ee2dd
@@ -296,7 +296,8 @@ void QgsVectorLayerProperties::toggleEditing()
{
emit toggleEditing( layer );

pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() && !layer->isEditable() );
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
if ( layer->isEditable() )
{
pbnQueryBuilder->setToolTip( tr( "Stop editing mode to enable this." ) );
@@ -474,7 +475,8 @@ void QgsVectorLayerProperties::reset( void )
// on the builder. If the ability to enter a query directly into the box is required,
// a mechanism to check it must be implemented.
txtSubsetSQL->setEnabled( false );
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() && !layer->isEditable() );
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
if ( layer->isEditable() )
{
pbnQueryBuilder->setToolTip( tr( "Stop editing mode to enable this." ) );
@@ -1079,6 +1081,8 @@ void QgsVectorLayerProperties::on_mButtonAddJoin_clicked()
layer->addJoin( info );
loadRows(); //update attribute tab
addJoinToTreeWidget( info );
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
}
}
}
@@ -1116,6 +1120,8 @@ void QgsVectorLayerProperties::on_mButtonRemoveJoin_clicked()
layer->removeJoin( currentJoinItem->data( 0, Qt::UserRole ).toString() );
loadRows();
mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) );
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
}

void QgsVectorLayerProperties::handleDiagramItemDoubleClick( QTreeWidgetItem * item, int column )
@@ -2693,6 +2693,7 @@ bool QgsVectorLayer::readXml( const QDomNode& layer_node )
mJoinBuffer->readXml( layer_node );

updateFieldMap();
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( checkJoinLayerRemove( QString ) ) );

QString errorMsg;
if ( !readSymbology( layer_node, errorMsg ) )
@@ -96,7 +96,11 @@ void QgsVectorLayerJoinBuffer::updateFieldMap( QgsFieldMap& fields, int& maxInde
QgsFieldMap::const_iterator fieldIt = joinFields.constBegin();
for ( ; fieldIt != joinFields.constEnd(); ++fieldIt )
{
fields.insert( maxIndex + 1 + fieldIt.key(), fieldIt.value() );
//skip the join field to avoid double field names (fields often have the same name)
if ( fieldIt.key() != joinIt->joinField )
{
fields.insert( maxIndex + 1 + fieldIt.key(), fieldIt.value() );
}
}

if ( maximumIndex( joinFields, currentMaxIndex ) )
@@ -217,6 +221,12 @@ void QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes( QgsFeature& f, const
QgsAttributeList::const_iterator attIt = attributes.constBegin();
for ( ; attIt != attributes.constEnd(); ++attIt )
{
//skip the join field to avoid double field names (fields often have the same name)
if ( *attIt == joinInfo.joinField )
{
continue;
}

if ( found )
{
f.addAttribute( *attIt + attributeIndexOffset, featureAttributes.value( *attIt ) );
@@ -24,7 +24,7 @@
#include <QHash>
#include <QString>

/**Manages joined field for a vector layer*/
/**Manages joined fields for a vector layer*/
class CORE_EXPORT QgsVectorLayerJoinBuffer
{
public:

0 comments on commit db20ac2

Please sign in to comment.
You can’t perform that action at this time.