mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 08:21:54 +02:00
allow deleting playlists with the delete key. fixes TWK-113
This commit is contained in:
parent
d61f38a206
commit
a9b792f603
@ -212,23 +212,23 @@ SourceTreeView::loadPlaylist()
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::deletePlaylist()
|
||||
SourceTreeView::deletePlaylist( const QModelIndex& idxIn )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
QModelIndex idx = m_contextMenuIndex;
|
||||
QModelIndex idx = idxIn.isValid() ? idxIn : m_contextMenuIndex;
|
||||
if ( !idx.isValid() )
|
||||
return;
|
||||
|
||||
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
|
||||
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( idx, SourcesModel::SourceTreeItemTypeRole ).toInt();
|
||||
if ( type == SourcesModel::StaticPlaylist )
|
||||
{
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( idx );
|
||||
playlist_ptr playlist = item->playlist();
|
||||
Playlist::remove( playlist );
|
||||
} else if( type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
|
||||
{
|
||||
DynamicPlaylistItem* item = itemFromIndex< DynamicPlaylistItem >( m_contextMenuIndex );
|
||||
DynamicPlaylistItem* item = itemFromIndex< DynamicPlaylistItem >( idx );
|
||||
dynplaylist_ptr playlist = item->dynPlaylist();
|
||||
DynamicPlaylist::remove( playlist );
|
||||
}
|
||||
@ -358,6 +358,25 @@ SourceTreeView::dropEvent( QDropEvent* event )
|
||||
m_dragging = false;
|
||||
}
|
||||
|
||||
void
|
||||
SourceTreeView::keyPressEvent( QKeyEvent *event )
|
||||
{
|
||||
if( !selectionModel()->selectedIndexes().isEmpty() )
|
||||
{
|
||||
QModelIndex idx = selectionModel()->selectedIndexes().first();
|
||||
if ( model()->data( idx, SourcesModel::SourceTreeItemTypeRole ) == SourcesModel::StaticPlaylist ||
|
||||
model()->data( idx, SourcesModel::SourceTreeItemTypeRole ) == SourcesModel::AutomaticPlaylist ||
|
||||
model()->data( idx, SourcesModel::SourceTreeItemTypeRole ) == SourcesModel::Station )
|
||||
{
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( idx );
|
||||
Q_ASSERT( item );
|
||||
|
||||
if( item->playlist()->author()->isLocal() ) {
|
||||
deletePlaylist( idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SourceTreeView::paintEvent( QPaintEvent* event )
|
||||
|
@ -52,7 +52,7 @@ private slots:
|
||||
void selectRequest( const QModelIndex& idx );
|
||||
|
||||
void loadPlaylist();
|
||||
void deletePlaylist();
|
||||
void deletePlaylist( const QModelIndex& = QModelIndex() );
|
||||
void copyPlaylistLink();
|
||||
|
||||
void onCustomContextMenu( const QPoint& pos );
|
||||
@ -66,6 +66,7 @@ protected:
|
||||
virtual void dragLeaveEvent( QDragLeaveEvent* event ) { Q_UNUSED( event ); m_dragging = false; setDirtyRegion( m_dropRect ); }
|
||||
virtual void dragMoveEvent( QDragMoveEvent* event );
|
||||
virtual void dropEvent( QDropEvent* event );
|
||||
virtual void keyPressEvent( QKeyEvent* event );
|
||||
|
||||
private:
|
||||
void setupMenus();
|
||||
|
2
thirdparty/jreen
vendored
2
thirdparty/jreen
vendored
@ -1 +1 @@
|
||||
Subproject commit a231a2b3868baf32312d65cb7e371828212d7745
|
||||
Subproject commit 8f995f246637f533feb7124744e113034a32b505
|
Loading…
x
Reference in New Issue
Block a user