]> git.sesse.net Git - vlc/commitdiff
Improved recognition of selected bookmarks for deletion.
authorEugen Geist <eugen.geist@gmail.com>
Mon, 23 Mar 2015 17:35:55 +0000 (17:35 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 24 Mar 2015 09:38:21 +0000 (10:38 +0100)
Removed FIXME annotation and fixed the recognition of selected rows in
bookmarklist.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/dialogs/bookmarks.cpp

index bfea0eb061f31f99d21958ddfe8a0e0470f70cae..4a8750c47dfbb431fef7b247bd62e1ef7f02a576 100644 (file)
@@ -179,20 +179,19 @@ void BookmarksDialog::del()
     input_thread_t *p_input = THEMIM->getInput();
     if( !p_input ) return;
 
-    QModelIndexList selected = bookmarksList->selectionModel()->selectedIndexes();
+    QModelIndexList selected = bookmarksList->selectionModel()->selectedRows();
     if ( !selected.empty() )
     {
         b_ignore_updates = true;
+        /* Sort needed to make sure that selected elements are deleted in descending
+           order, otherwise the indexes might change and wrong bookmarks are deleted. */
+        qSort( selected.begin(), selected.end() );
         QModelIndexList::Iterator it = selected.end();
         for( --it; it != selected.begin(); it-- )
         {
-            /* FIXME: Find out why selectedIndexes() doesn't follow the
-            SelectRows selectionBehavior() and returns all columns */
-            if ( (*it).column() == 0 )
-                input_Control( p_input, INPUT_DEL_BOOKMARK, (*it).row() );
-        }
-        if ( (*it).column() == 0 )
             input_Control( p_input, INPUT_DEL_BOOKMARK, (*it).row() );
+        }
+        input_Control( p_input, INPUT_DEL_BOOKMARK, (*it).row() );
         b_ignore_updates = false;
         update();
     }