Commit 5e674f08 authored by François Cartegnie's avatar François Cartegnie 🤞

Qt: BookMarks dialog: correctly handle deleting selection

parent 1debd199
......@@ -31,9 +31,11 @@
#include <QSpacerItem>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QModelIndexList>
BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf )
{
b_ignore_updates = false;
setWindowFlags( Qt::Tool );
setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) );
setWindowTitle( qtr( "Edit Bookmarks" ) );
......@@ -118,6 +120,7 @@ void BookmarksDialog::updateButtons()
void BookmarksDialog::update()
{
if ( b_ignore_updates ) return;
input_thread_t *p_input = THEMIM->getInput();
if( !p_input ) return;
......@@ -176,11 +179,22 @@ void BookmarksDialog::del()
input_thread_t *p_input = THEMIM->getInput();
if( !p_input ) return;
int i_focused = bookmarksList->currentIndex().row();
if( i_focused >= 0 )
QModelIndexList selected = bookmarksList->selectionModel()->selectedIndexes();
if ( !selected.empty() )
{
input_Control( p_input, INPUT_DEL_BOOKMARK, i_focused );
b_ignore_updates = true;
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() );
b_ignore_updates = false;
update();
}
}
......
......@@ -42,6 +42,7 @@ private:
QTreeWidget *bookmarksList;
QPushButton *clearButton;
QPushButton *delButton;
bool b_ignore_updates;
private slots:
void update();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment