Skip to content
Permalink
Browse files

[joins] editing keeps the same order and selection in GUI

  • Loading branch information
3nids committed Mar 12, 2015
1 parent 1810cdd commit a9e58e66d8290dad2f343a2f1ea7adbbfb91cbd2
Showing with 14 additions and 6 deletions.
  1. +13 −5 src/app/qgsvectorlayerproperties.cpp
  2. +1 −1 src/app/qgsvectorlayerproperties.h
@@ -1099,11 +1099,11 @@ void QgsVectorLayerProperties::on_mButtonEditJoin_clicked()

// remove old join
layer->removeJoin( joinLayerId );
mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) );
int idx = mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem );
mJoinTreeWidget->takeTopLevelItem( idx );

// add the new edited


//create attribute index if possible
if ( d.createAttributeIndex() )
{
@@ -1114,15 +1114,15 @@ void QgsVectorLayerProperties::on_mButtonEditJoin_clicked()
}
}
layer->addJoin( info );
addJoinToTreeWidget( info );
addJoinToTreeWidget( info, idx );

pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
mFieldsPropertiesDialog->init();
}
}

void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorJoinInfo& join )
void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorJoinInfo& join, const int insertIndex )
{
QTreeWidgetItem* joinItem = new QTreeWidgetItem();

@@ -1170,11 +1170,19 @@ void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorJoinInfo& joi
joinItem->setText( 5, tr( "all" ) );
}

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

void QgsVectorLayerProperties::on_mButtonRemoveJoin_clicked()
@@ -181,7 +181,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
//QPixmap bufferPixmap;

/**Adds a new join to mJoinTreeWidget*/
void addJoinToTreeWidget( const QgsVectorJoinInfo& join );
void addJoinToTreeWidget( const QgsVectorJoinInfo& join , const int insertIndex = -1 );
};

inline QString QgsVectorLayerProperties::displayName()

0 comments on commit a9e58e6

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