mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
allow deleting playlists with the delete key. fixes TWK-113
This commit is contained in:
@@ -212,23 +212,23 @@ SourceTreeView::loadPlaylist()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreeView::deletePlaylist()
|
SourceTreeView::deletePlaylist( const QModelIndex& idxIn )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
QModelIndex idx = m_contextMenuIndex;
|
QModelIndex idx = idxIn.isValid() ? idxIn : m_contextMenuIndex;
|
||||||
if ( !idx.isValid() )
|
if ( !idx.isValid() )
|
||||||
return;
|
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 )
|
if ( type == SourcesModel::StaticPlaylist )
|
||||||
{
|
{
|
||||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
PlaylistItem* item = itemFromIndex< PlaylistItem >( idx );
|
||||||
playlist_ptr playlist = item->playlist();
|
playlist_ptr playlist = item->playlist();
|
||||||
Playlist::remove( playlist );
|
Playlist::remove( playlist );
|
||||||
} else if( type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
|
} else if( type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
|
||||||
{
|
{
|
||||||
DynamicPlaylistItem* item = itemFromIndex< DynamicPlaylistItem >( m_contextMenuIndex );
|
DynamicPlaylistItem* item = itemFromIndex< DynamicPlaylistItem >( idx );
|
||||||
dynplaylist_ptr playlist = item->dynPlaylist();
|
dynplaylist_ptr playlist = item->dynPlaylist();
|
||||||
DynamicPlaylist::remove( playlist );
|
DynamicPlaylist::remove( playlist );
|
||||||
}
|
}
|
||||||
@@ -358,6 +358,25 @@ SourceTreeView::dropEvent( QDropEvent* event )
|
|||||||
m_dragging = false;
|
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
|
void
|
||||||
SourceTreeView::paintEvent( QPaintEvent* event )
|
SourceTreeView::paintEvent( QPaintEvent* event )
|
||||||
|
@@ -52,7 +52,7 @@ private slots:
|
|||||||
void selectRequest( const QModelIndex& idx );
|
void selectRequest( const QModelIndex& idx );
|
||||||
|
|
||||||
void loadPlaylist();
|
void loadPlaylist();
|
||||||
void deletePlaylist();
|
void deletePlaylist( const QModelIndex& = QModelIndex() );
|
||||||
void copyPlaylistLink();
|
void copyPlaylistLink();
|
||||||
|
|
||||||
void onCustomContextMenu( const QPoint& pos );
|
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 dragLeaveEvent( QDragLeaveEvent* event ) { Q_UNUSED( event ); m_dragging = false; setDirtyRegion( m_dropRect ); }
|
||||||
virtual void dragMoveEvent( QDragMoveEvent* event );
|
virtual void dragMoveEvent( QDragMoveEvent* event );
|
||||||
virtual void dropEvent( QDropEvent* event );
|
virtual void dropEvent( QDropEvent* event );
|
||||||
|
virtual void keyPressEvent( QKeyEvent* event );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupMenus();
|
void setupMenus();
|
||||||
|
2
thirdparty/jreen
vendored
2
thirdparty/jreen
vendored
Submodule thirdparty/jreen updated: a231a2b386...8f995f2466
Reference in New Issue
Block a user