File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -202,16 +202,17 @@ void QgsBookmarks::addClicked()
202202
203203void 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
231234void QgsBookmarks::lstBookmarks_doubleClicked ( const QModelIndex &index )
You can’t perform that action at this time.
0 commit comments