[amarok] /: Separate delete and trash collection tree actions
Bart Cerneels
bart.cerneels at kde.org
Mon Nov 14 18:53:24 UTC 2011
I think this one should be reverted. It adds one more entry in an
already long menu (comfortable max is 5). And this creates the
possibility of accidental data loss.
Preferred fix: delete action on iPod collection. This needs some
refactoring I think.
On Sat, Nov 12, 2011 at 16:13, Matěj Laitl <matej at laitl.cz> wrote:
> Git commit 3c2f14dd62241312275b5a5b821dba0a628a37ed by Matěj Laitl.
> Committed on 12/11/2011 at 16:01.
> Pushed by laitl into branch 'master'.
>
> Separate delete and trash collection tree actions
>
> The "delete" action was previously only accessible through holding
> Shift when clicking Delete, which was secret, inconsistent and
> inconvenient. The old shift + click behaviour is not preserved.
>
> BUG: 286356
> FIXED-IN: 2.5
> GUI: Move to Trash action added to collection browser context menu
> Handbook needs updating.
>
> M +2 -0 ChangeLog
> M +32 -23 src/browsers/CollectionTreeView.cpp
> M +2 -1 src/browsers/CollectionTreeView.h
>
> http://commits.kde.org/amarok/3c2f14dd62241312275b5a5b821dba0a628a37ed
>
> diff --git a/ChangeLog b/ChangeLog
> index 54b9a87..9376afd 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -26,6 +26,8 @@ Version 2.5.0-Beta 1
> * Auto-save the playlist so that it is not lost if Amarok crashes.
>
> CHANGES:
> + * Both Delete and Move to Trash actions are now offered in the collection
> + browser context menu. (BR 286356)
> * Amarok now depends on libmygpo-qt > 1.0.5.
> * New USB Mass Storage media-device plugin using the Amarok Collection Scanner.
> * Browser widget backgrounds can now be enabled/disabled.
> diff --git a/src/browsers/CollectionTreeView.cpp b/src/browsers/CollectionTreeView.cpp
> index ecb009e..c9069c7 100644
> --- a/src/browsers/CollectionTreeView.cpp
> +++ b/src/browsers/CollectionTreeView.cpp
> @@ -1063,23 +1063,24 @@ QHash<QAction*, Collections::Collection*> CollectionTreeView::getRemoveActions(
> {
> QHash<QAction*, Collections::Collection*> currentRemoveDestination;
>
> - if( onlyOneCollection( indices) )
> - {
> - Collections::Collection *collection = getCollection( indices.first() );
> - if( collection && collection->isWritable() )
> - {
> - //writableCollections.append( collection );
> - KAction *action = new KAction( KIcon( "remove-amarok" ), i18n( "Delete Tracks" ), 0 );
> - action->setProperty( "popupdropper_svg_id", "delete" );
> -
> - connect( action, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)),
> - this, SLOT(slotRemoveTracks(Qt::MouseButtons,Qt::KeyboardModifiers)) );
> + if( !onlyOneCollection( indices ) )
> + return currentRemoveDestination;
> + Collections::Collection *collection = getCollection( indices.first() );
> + if( !collection || !collection->isWritable() )
> + return currentRemoveDestination;
> +
> + KAction *trashAction = new KAction( KIcon( "user-trash" ), i18n( "Move Tracks to Trash" ), 0 );
> + trashAction->setProperty( "popupdropper_svg_id", "delete" );
> + connect( trashAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)),
> + this, SLOT(slotTrashTracks()) );
> + currentRemoveDestination.insert( trashAction, collection );
> +
> + KAction *deleteAction = new KAction( KIcon( "remove-amarok" ), i18n( "Delete Tracks" ), 0 );
> + deleteAction->setProperty( "popupdropper_svg_id", "delete" );
> + connect( deleteAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)),
> + this, SLOT(slotRemoveTracks()) );
> + currentRemoveDestination.insert( deleteAction, collection );
>
> - currentRemoveDestination.insert( action, collection );
> - }
> -
> -
> - }
> return currentRemoveDestination;
> }
>
> @@ -1173,15 +1174,23 @@ void CollectionTreeView::slotMoveTracks()
> }
> }
>
> -void CollectionTreeView::slotRemoveTracks( Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers )
> +void
> +CollectionTreeView::slotTrashTracks()
> {
> - Q_UNUSED( buttons )
> KAction *action = qobject_cast<KAction*>( sender() );
> - if( action )
> - {
> - bool skipTrash = modifiers.testFlag( Qt::ShiftModifier );
> - removeTracks( m_currentItems, !skipTrash );
> - }
> + if( !action )
> + return;
> + // TODO: can use m_currentRemoveDestination[ action ] and pass it to removeTracks()
> + removeTracks( m_currentItems, true /* use trash */ );
> +}
> +
> +void CollectionTreeView::slotRemoveTracks()
> +{
> + KAction *action = qobject_cast<KAction*>( sender() );
> + if( !action )
> + return;
> + // TODO: can use m_currentRemoveDestination[ action ] and pass it to removeTracks()
> + removeTracks( m_currentItems, false /* do not use trash */ );
> }
>
> void CollectionTreeView::slotOrganize()
> diff --git a/src/browsers/CollectionTreeView.h b/src/browsers/CollectionTreeView.h
> index 9ed71e0..b70f99d 100644
> --- a/src/browsers/CollectionTreeView.h
> +++ b/src/browsers/CollectionTreeView.h
> @@ -85,7 +85,8 @@ class CollectionTreeView: public Amarok::PrettyTreeView
> void slotEditTracks();
> void slotCopyTracks();
> void slotMoveTracks();
> - void slotRemoveTracks( Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers );
> + void slotTrashTracks();
> + void slotRemoveTracks();
> void slotOrganize();
>
> private:
>
More information about the Amarok-devel
mailing list