Skip to content
Permalink
Browse files

Merge pull request #1964 from mhugo/fix_querybuilder_joins2

Allow provider-level filtering (subset string) on layers with joined fields
  • Loading branch information
m-kuhn committed Mar 26, 2015
2 parents 837c7ee + 4a52750 commit 5b5f16e8ffdd70cf97c07825715e7a11a02970bc
@@ -148,7 +148,7 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
menu->addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) );
menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) );

if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() && vlayer->vectorJoins().isEmpty() )
if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() )
menu->addAction( tr( "&Filter..." ), QgisApp::instance(), SLOT( layerSubsetString() ) );

menu->addAction( actions->actionShowFeatureCount( menu ) );
@@ -306,7 +306,7 @@ void QgsVectorLayerProperties::toggleEditing()
emit toggleEditing( layer );

pbnQueryBuilder->setEnabled( layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
!layer->isEditable() );
if ( layer->isEditable() )
{
pbnQueryBuilder->setToolTip( tr( "Stop editing mode to enable this." ) );
@@ -392,7 +392,7 @@ void QgsVectorLayerProperties::syncToLayer( void )
// a mechanism to check it must be implemented.
txtSubsetSQL->setEnabled( false );
pbnQueryBuilder->setEnabled( layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
!layer->isEditable() );
if ( layer->isEditable() )
{
pbnQueryBuilder->setToolTip( tr( "Stop editing mode to enable this." ) );
@@ -1056,7 +1056,7 @@ void QgsVectorLayerProperties::on_mButtonAddJoin_clicked()
layer->addJoin( info );
addJoinToTreeWidget( info );
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
!layer->isEditable() );
mFieldsPropertiesDialog->init();
}
}
@@ -1117,7 +1117,7 @@ void QgsVectorLayerProperties::on_mButtonEditJoin_clicked()
addJoinToTreeWidget( info, idx );

pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
!layer->isEditable() );
mFieldsPropertiesDialog->init();
}
}
@@ -1196,7 +1196,7 @@ void QgsVectorLayerProperties::on_mButtonRemoveJoin_clicked()
layer->removeJoin( currentJoinItem->data( 0, Qt::UserRole ).toString() );
mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) );
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
!layer->isEditable() );
mFieldsPropertiesDialog->init();
}

@@ -72,6 +72,11 @@ void QgsQueryBuilder::populateFields()
const QgsFields& fields = mLayer->pendingFields();
for ( int idx = 0; idx < fields.count(); ++idx )
{
if ( fields.fieldOrigin(idx) != QgsFields::OriginProvider )
{
// only consider native fields
continue;
}
QStandardItem *myItem = new QStandardItem( fields[idx].name() );
myItem->setData( idx );
myItem->setEditable( false );

0 comments on commit 5b5f16e

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