Skip to content
Permalink
Browse files

fix bookmark deletion

  • Loading branch information
stevenmizuno committed Jan 1, 2018
1 parent 771288e commit 4eb454843cc33a98b73206e1152f51b05839f78c
Showing with 10 additions and 7 deletions.
  1. +10 −7 src/app/qgsbookmarks.cpp
@@ -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
@@ -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 )

0 comments on commit 4eb4548

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