Skip to content

Commit 4eb4548

Browse files
committed
fix bookmark deletion
1 parent 771288e commit 4eb4548

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/app/qgsbookmarks.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,17 @@ void QgsBookmarks::addClicked()
202202

203203
void QgsBookmarks::deleteClicked()
204204
{
205-
QList<int> rows;
206-
Q_FOREACH ( const QModelIndex &idx, lstBookmarks->selectionModel()->selectedIndexes() )
205+
QItemSelection selection( mProxyModel->mapSelectionToSource( lstBookmarks->selectionModel()->selection() ) );
206+
std::vector<int> rows;
207+
Q_FOREACH ( const QModelIndex &idx, selection.indexes() )
207208
{
208209
if ( idx.column() == 1 )
209210
{
210-
rows << idx.row();
211+
rows.push_back( idx.row() );
211212
}
212213
}
213214

214-
if ( rows.isEmpty() )
215+
if ( rows.size() == 0 )
215216
return;
216217

217218
// make sure the user really wants to delete these bookmarks
@@ -220,12 +221,14 @@ void QgsBookmarks::deleteClicked()
220221
QMessageBox::Ok | QMessageBox::Cancel ) )
221222
return;
222223

223-
int i = 0;
224+
// Remove in reverse order to keep the merged model indexes
225+
std::sort( rows.begin(), rows.end(), std::greater<int>() );
226+
224227
Q_FOREACH ( int row, rows )
225228
{
226-
mMergedModel->removeRow( row - i );
227-
i++;
229+
mMergedModel->removeRow( row );
228230
}
231+
mProxyModel->_resetModel();
229232
}
230233

231234
void QgsBookmarks::lstBookmarks_doubleClicked( const QModelIndex &index )

0 commit comments

Comments
 (0)