Skip to content

Commit

Permalink
fix bookmark deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmizuno committed Jan 8, 2018
1 parent 771288e commit 4eb4548
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/app/qgsbookmarks.cpp
Expand Up @@ -202,16 +202,17 @@ void QgsBookmarks::addClicked()

void QgsBookmarks::deleteClicked()
{
QList<int> rows;
Q_FOREACH ( const QModelIndex &idx, lstBookmarks->selectionModel()->selectedIndexes() )
QItemSelection selection( mProxyModel->mapSelectionToSource( lstBookmarks->selectionModel()->selection() ) );
std::vector<int> rows;
Q_FOREACH ( const QModelIndex &idx, selection.indexes() )
{
if ( idx.column() == 1 )
{
rows << idx.row();
rows.push_back( idx.row() );
}
}

if ( rows.isEmpty() )
if ( rows.size() == 0 )
return;

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

int i = 0;
// Remove in reverse order to keep the merged model indexes
std::sort( rows.begin(), rows.end(), std::greater<int>() );

Q_FOREACH ( int row, rows )
{
mMergedModel->removeRow( row - i );
i++;
mMergedModel->removeRow( row );
}
mProxyModel->_resetModel();
}

void QgsBookmarks::lstBookmarks_doubleClicked( const QModelIndex &index )
Expand Down

0 comments on commit 4eb4548

Please sign in to comment.