Skip to content

Commit

Permalink
make it possible to remove multiple selected entries in batch and pla…
Browse files Browse the repository at this point in the history
…ylist downloader tabs
  • Loading branch information
mhogomchungu committed Oct 4, 2024
1 parent 1353865 commit 7273a2e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/batchdownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ void batchdownloader::showCustomContext()

connect( ac,&QAction::triggered,[ this,row ](){

m_table.removeRow( row ) ;
Q_UNUSED( row )

//m_table.removeRow( row ) ;

m_table.removeAllSelected() ;

m_ui.pbBDDownload->setEnabled( m_table.rowCount() ) ;
} ) ;
Expand Down
6 changes: 5 additions & 1 deletion src/playlistdownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,11 @@ void playlistdownloader::customContextMenuRequested()

connect( ac,&QAction::triggered,[ this,row ](){

m_table.removeRow( row ) ;
Q_UNUSED( row ) ;

//m_table.removeRow( row ) ;

m_table.removeAllSelected() ;

m_ui.pbBDDownload->setEnabled( m_table.rowCount() ) ;
} ) ;
Expand Down
20 changes: 20 additions & 0 deletions src/tableWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,26 @@ void tableWidget::removeRow( int s )
m_items.erase( m_items.begin() + s ) ;
}

void tableWidget::removeAllSelected()
{
std::vector< int > selected ;

auto col = m_table.columnCount() - 1 ;

for( int i = 0 ; i < m_table.rowCount() ; i++ ){

if( m_table.item( i,col )->isSelected() ){

selected.emplace_back( i ) ;
}
}

for( auto it = selected.rbegin() ; it != selected.rend() ; it++ ){

this->removeRow( *it ) ;
}
}

void tableWidget::hideRow( int row )
{
m_table.hideRow( row ) ;
Expand Down
1 change: 1 addition & 0 deletions src/tableWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ class tableWidget
void selectRow( int ) ;
void setEnabled( bool ) ;
void removeRow( int ) ;
void removeAllSelected() ;
void hideRow( int ) ;
bool isSelected( int ) ;
bool noneAreRunning() ;
Expand Down

0 comments on commit 7273a2e

Please sign in to comment.