Commit caa0eba8 authored by Bart Cerneels's avatar Bart Cerneels
Browse files

Ask delete confirmation for all contents of folder.

BUG:246117
parent fbdeaaa6
......@@ -34,6 +34,8 @@ VERSION 2.4.1
<bhargav.1191@gmail.com>. (BR 248690)
BUGFIXES:
* Ask delete confirmation for all contents of folder at once instead of each individually.
Affects "Saved Playlists" and "Podcasts" (BR 246117)
* Fixed unreadable text in lyrics applet in kde 4.6. (BR 265311)
* Fixed tag dialog crash when sorting by genre and then changing tags.
* Fixed track's statistics update in case of StopAfterCurrent playback mode
......
......@@ -23,9 +23,12 @@
#include "UserPlaylistModel.h"
#include "playlist/PlaylistModelStack.h"
#include <KDialog>
#include <KIcon>
#include <KInputDialog>
#include <QLabel>
PlaylistsInFoldersProxy::PlaylistsInFoldersProxy( QAbstractItemModel *model )
: QtGroupingProxy( model, QModelIndex(), PlaylistBrowserNS::UserModel::LabelColumn )
{
......@@ -120,7 +123,6 @@ PlaylistsInFoldersProxy::removeRows( int row, int count, const QModelIndex &pare
result = true;
for( int i = row; i < row + count; i++ )
{
//individually remove all children of this group in the source model
QModelIndex childIdx = mapToSource( index( i, 0, parent ) );
//set success to false if removeRows returns false
result = sourceModel()->removeRow( childIdx.row(), QModelIndex() ) ? result : false;
......@@ -326,7 +328,21 @@ PlaylistsInFoldersProxy::deleteFolder( const QModelIndex &groupIdx )
{
int childCount = rowCount( groupIdx );
if( childCount > 0 )
{
KDialog dialog;
dialog.setCaption( i18n( "Confirm Delete" ) );
dialog.setButtons( KDialog::Ok | KDialog::Cancel );
QLabel label( i18n( "Are you sure you want to delete this folder and it's contents?" )
, &dialog
);
//TODO:include a text area with all the names of the playlists
dialog.setButtonText( KDialog::Ok, i18n( "Yes, delete folder." ) );
dialog.setMainWidget( &label );
if( dialog.exec() != QDialog::Accepted )
return;
removeRows( 0, childCount, groupIdx );
}
removeGroup( groupIdx );
}
......
......@@ -627,7 +627,6 @@ QtGroupingProxy::addEmptyGroup( const RowData &data )
bool
QtGroupingProxy::removeGroup( const QModelIndex &idx )
{
//TODO:unset this groups value from the childrens grouped column
beginRemoveRows( idx.parent(), idx.row(), idx.row() );
m_groupHash.remove( idx.row() );
m_groupMaps.removeAt( idx.row() );
......@@ -700,9 +699,21 @@ QtGroupingProxy::modelRowsRemoved( const QModelIndex &parent, int start, int end
{
if( parent == m_rootNode )
{
//rebuild tree, reseting the view
//TODO: don't rebuild but remove from
buildTree();
//do this separate for each row
for( int i = start; i <= end; i++ )
{
foreach( int groupIndex, m_groupHash.keys() )
{
int rowIndex = m_groupHash[groupIndex].indexOf( i );
if( rowIndex == -1 )
continue;
QModelIndex proxyParent = index( groupIndex, 0 );
beginRemoveRows( proxyParent, rowIndex, rowIndex );
m_groupHash[groupIndex].removeAt( rowIndex );
endRemoveRows();
}
}
return;
}
......
......@@ -327,20 +327,6 @@ PlaylistFileProvider::deletePlaylists( Playlists::PlaylistList playlists )
bool
PlaylistFileProvider::deletePlaylistFiles( Playlists::PlaylistFileList playlistFiles )
{
DEBUG_BLOCK
KDialog dialog;
dialog.setCaption( i18n( "Confirm Delete" ) );
dialog.setButtons( KDialog::Ok | KDialog::Cancel );
QLabel label( i18np( "Are you sure you want to delete this playlist?",
"Are you sure you want to delete these %1 playlist files?",
playlistFiles.count() )
, &dialog
);
dialog.setButtonText( KDialog::Ok, i18n( "Yes, delete from disk." ) );
dialog.setMainWidget( &label );
if( dialog.exec() != QDialog::Accepted )
return false;
foreach( Playlists::PlaylistFilePtr playlistFile, playlistFiles )
{
m_playlists.removeAll( playlistFile );
......@@ -425,7 +411,21 @@ PlaylistFileProvider::slotDelete()
//only one playlist can be selected at this point
Playlists::PlaylistFileList playlists = action->data().value<Playlists::PlaylistFileList>();
if( playlists.count() > 0 )
if( playlists.count() == 0 )
return;
KDialog dialog;
dialog.setCaption( i18n( "Confirm Delete" ) );
dialog.setButtons( KDialog::Ok | KDialog::Cancel );
QLabel label( i18np( "Are you sure you want to delete this playlist?",
"Are you sure you want to delete these %1 playlist files?",
playlists.count() )
, &dialog
);
//TODO:include a text area with all the names of the playlists
dialog.setButtonText( KDialog::Ok, i18n( "Yes, delete from disk." ) );
dialog.setMainWidget( &label );
if( dialog.exec() == QDialog::Accepted )
deletePlaylistFiles( playlists );
}
......
......@@ -108,8 +108,27 @@ SqlUserPlaylistProvider::slotDelete()
//only one playlist can be selected at this point
Playlists::SqlPlaylistList playlists = action->data().value<Playlists::SqlPlaylistList>();
if( playlists.count() > 0 )
deleteSqlPlaylists( playlists );
if( playlists.count() == 0 )
return;
if( !m_debug )
{
KDialog dialog;
dialog.setCaption( i18n( "Confirm Delete" ) );
dialog.setButtons( KDialog::Ok | KDialog::Cancel );
QLabel label( i18np( "Are you sure you want to delete this playlist?",
"Are you sure you want to delete these %1 playlists?",
playlists.count() )
, &dialog
);
//TODO:include a text area with all the names of the playlists
dialog.setButtonText( KDialog::Ok, i18n( "Yes, delete from database." ) );
dialog.setMainWidget( &label );
if( dialog.exec() != QDialog::Accepted )
return;
}
deleteSqlPlaylists( playlists );
}
void
......@@ -246,22 +265,7 @@ SqlUserPlaylistProvider::deletePlaylists( Playlists::PlaylistList playlistList )
bool
SqlUserPlaylistProvider::deleteSqlPlaylists( Playlists::SqlPlaylistList playlistList )
{
if( !m_debug )
{
KDialog dialog;
dialog.setCaption( i18n( "Confirm Delete" ) );
dialog.setButtons( KDialog::Ok | KDialog::Cancel );
QLabel label( i18np( "Are you sure you want to delete this playlist?",
"Are you sure you want to delete these %1 playlists?",
playlistList.count() )
, &dialog
);
dialog.setButtonText( KDialog::Ok, i18n( "Yes, delete from database." ) );
dialog.setMainWidget( &label );
if( dialog.exec() != QDialog::Accepted )
return false;
}
//this delete is not confirmed, has to be done by the slot connected to the delete action.
foreach( Playlists::SqlPlaylistPtr sqlPlaylist, playlistList )
{
if( sqlPlaylist )
......
Supports Markdown
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