Skip to content

Commit a9e58e6

Browse files
committedMar 12, 2015
[joins] editing keeps the same order and selection in GUI
1 parent 1810cdd commit a9e58e6

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed
 

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,11 +1099,11 @@ void QgsVectorLayerProperties::on_mButtonEditJoin_clicked()
10991099

11001100
// remove old join
11011101
layer->removeJoin( joinLayerId );
1102-
mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) );
1102+
int idx = mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem );
1103+
mJoinTreeWidget->takeTopLevelItem( idx );
11031104

11041105
// add the new edited
11051106

1106-
11071107
//create attribute index if possible
11081108
if ( d.createAttributeIndex() )
11091109
{
@@ -1114,15 +1114,15 @@ void QgsVectorLayerProperties::on_mButtonEditJoin_clicked()
11141114
}
11151115
}
11161116
layer->addJoin( info );
1117-
addJoinToTreeWidget( info );
1117+
addJoinToTreeWidget( info, idx );
11181118

11191119
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
11201120
!layer->isEditable() && layer->vectorJoins().size() < 1 );
11211121
mFieldsPropertiesDialog->init();
11221122
}
11231123
}
11241124

1125-
void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorJoinInfo& join )
1125+
void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorJoinInfo& join, const int insertIndex )
11261126
{
11271127
QTreeWidgetItem* joinItem = new QTreeWidgetItem();
11281128

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

1173-
mJoinTreeWidget->addTopLevelItem( joinItem );
1173+
if ( insertIndex >= 0 )
1174+
{
1175+
mJoinTreeWidget->insertTopLevelItem( insertIndex, joinItem );
1176+
}
1177+
else
1178+
{
1179+
mJoinTreeWidget->addTopLevelItem( joinItem );
1180+
}
11741181
for ( int c = 0; c < 5; c++ )
11751182
{
11761183
mJoinTreeWidget->resizeColumnToContents( c );
11771184
}
1185+
mJoinTreeWidget->setCurrentItem( joinItem );
11781186
}
11791187

11801188
void QgsVectorLayerProperties::on_mButtonRemoveJoin_clicked()

‎src/app/qgsvectorlayerproperties.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
181181
//QPixmap bufferPixmap;
182182

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

187187
inline QString QgsVectorLayerProperties::displayName()

0 commit comments

Comments
 (0)
Please sign in to comment.