Skip to content
Permalink
Browse files

Update vector layer properties ui list for join

  • Loading branch information
pblottiere committed Aug 3, 2017
1 parent 3a0ab23 commit 9df519f13f34e8609e496cb221ab371ff8960c42
Showing with 345 additions and 118 deletions.
  1. +51 −33 src/app/qgsvectorlayerproperties.cpp
  2. +294 −85 src/ui/qgsvectorlayerpropertiesbase.ui
@@ -1218,69 +1218,87 @@ void QgsVectorLayerProperties::on_mJoinTreeWidget_itemDoubleClicked( QTreeWidget
void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorLayerJoinInfo &join, const int insertIndex )
{
QTreeWidgetItem *joinItem = new QTreeWidgetItem();
joinItem->setFlags( Qt::ItemIsEnabled );

QgsVectorLayer *joinLayer = join.joinLayer();
if ( !mLayer || !joinLayer )
{
return;
}

joinItem->setText( 0, joinLayer->name() );
joinItem->setText( 0, "Join layer" );
joinItem->setText( 1, joinLayer->name() );

QFont f = joinItem->font( 0 );
f.setBold( true );
joinItem->setFont( 0, f );
joinItem->setFont( 1, f );

joinItem->setData( 0, Qt::UserRole, join.joinLayerId() );

joinItem->setText( 1, join.joinFieldName() );
joinItem->setText( 2, join.targetFieldName() );
QTreeWidgetItem *childJoinField = new QTreeWidgetItem();
childJoinField->setText( 0, "Join field" );
childJoinField->setText( 1, join.joinFieldName() );
childJoinField->setFlags( Qt::ItemIsEnabled );
joinItem->addChild( childJoinField );

QTreeWidgetItem *childTargetField = new QTreeWidgetItem();
childTargetField->setText( 0, "Target field" );
childTargetField->setText( 1, join.targetFieldName() );
joinItem->addChild( childTargetField );

QTreeWidgetItem *childMemCache = new QTreeWidgetItem();
childMemCache->setText( 0, "Cache join layer in virtual memory" );
if ( join.isUsingMemoryCache() )
{
joinItem->setText( 3, QChar( 0x2714 ) );
}
childMemCache->setText( 1, QChar( 0x2714 ) );
joinItem->addChild( childMemCache );

QTreeWidgetItem *childDynForm = new QTreeWidgetItem();
childDynForm->setText( 0, "Dynamic form" );
if ( join.isDynamicFormEnabled() )
{
joinItem->setText( 4, QChar( 0x2714 ) );
}
childDynForm->setText( 1, QChar( 0x2714 ) );
joinItem->addChild( childDynForm );

QTreeWidgetItem *childEditable = new QTreeWidgetItem();
childEditable->setText( 0, "Editable join layer" );
if ( join.isEditable() )
{
joinItem->setText( 5, QChar( 0x2714 ) );
}
childEditable->setText( 1, QChar( 0x2714 ) );
joinItem->addChild( childEditable );

QTreeWidgetItem *childUpsert = new QTreeWidgetItem();
childUpsert->setText( 0, "Upsert on edit" );
if ( join.hasUpsertOnEdit() )
{
joinItem->setText( 6, QChar( 0x2714 ) );
}
childUpsert->setText( 1, QChar( 0x2714 ) );
joinItem->addChild( childUpsert );

QTreeWidgetItem *childCascade = new QTreeWidgetItem();
childCascade->setText( 0, "Delete cascade" );
if ( join.hasCascadedDelete() )
{
joinItem->setText( 7, QChar( 0x2714 ) );
}
childCascade->setText( 1, QChar( 0x2714 ) );
joinItem->addChild( childCascade );

joinItem->setText( 8, join.prefix() );
QTreeWidgetItem *childPrefix = new QTreeWidgetItem();
childPrefix->setText( 0, "Custom field name prefix" );
childPrefix->setText( 1, join.prefix() );
joinItem->addChild( childPrefix );

QTreeWidgetItem *childFields = new QTreeWidgetItem();
childFields->setText( 0, "Joined fields" );
const QStringList *list = join.joinFieldNamesSubset();
QString fields;
if ( list )
{
joinItem->setText( 9, QStringLiteral( "%1" ).arg( list->count() ) );
}
childFields->setText( 1, QStringLiteral( "%1" ).arg( list->count() ) );
else
{
joinItem->setText( 9, tr( "all" ) );
}
childFields->setText( 1, tr( "all" ) );
joinItem->addChild( childFields );

if ( insertIndex >= 0 )
{
mJoinTreeWidget->insertTopLevelItem( insertIndex, joinItem );
}
else
{
mJoinTreeWidget->addTopLevelItem( joinItem );
}
for ( int c = 0; c < 9; c++ )
{
mJoinTreeWidget->resizeColumnToContents( c );
}

mJoinTreeWidget->setCurrentItem( joinItem );
mJoinTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
}

QgsExpressionContext QgsVectorLayerProperties::createExpressionContext() const

0 comments on commit 9df519f

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