mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 22:56:42 +02:00
add some handling of dynamic playlists in the sourcelist
This commit is contained in:
@@ -243,15 +243,18 @@ SourcesModel::setData( const QModelIndex& index, const QVariant& value, int role
|
|||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
playlist_ptr playlist;
|
||||||
if ( indexType( index ) == PlaylistSource )
|
if ( indexType( index ) == PlaylistSource )
|
||||||
{
|
{
|
||||||
playlist_ptr playlist = indexToPlaylist( index );
|
playlist = indexToPlaylist( index );
|
||||||
|
} else if ( indexType( index ) == DynamicPlaylistSource ) {
|
||||||
|
playlist = indexToDynamicPlaylist( index ).staticCast< Playlist >();
|
||||||
|
}
|
||||||
|
|
||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
{
|
{
|
||||||
playlist->rename( value.toString() );
|
playlist->rename( value.toString() );
|
||||||
QStandardItemModel::setData( index, value, Qt::DisplayRole );
|
QStandardItemModel::setData( index, value, Qt::DisplayRole );
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ protected:
|
|||||||
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
void updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
void updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
if ( SourcesModel::indexType( index ) == 1 )
|
if ( SourcesModel::indexType( index ) == SourcesModel::PlaylistSource || SourcesModel::indexType( index ) == SourcesModel::DynamicPlaylistSource )
|
||||||
editor->setGeometry( option.rect.adjusted( 32, 0, 0, 0 ) );
|
editor->setGeometry( option.rect.adjusted( 32, 0, 0, 0 ) );
|
||||||
else
|
else
|
||||||
QStyledItemDelegate::updateEditorGeometry( editor, option, index );
|
QStyledItemDelegate::updateEditorGeometry( editor, option, index );
|
||||||
@@ -185,9 +185,11 @@ SourceTreeView::deletePlaylist()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SourcesModel::SourceType type = SourcesModel::indexType( idx );
|
SourcesModel::SourceType type = SourcesModel::indexType( idx );
|
||||||
if ( type == SourcesModel::PlaylistSource )
|
if ( type == SourcesModel::PlaylistSource || type == SourcesModel::DynamicPlaylistSource )
|
||||||
{
|
{
|
||||||
playlist_ptr playlist = SourcesModel::indexToPlaylist( idx );
|
playlist_ptr playlist = ( type == SourcesModel::DynamicPlaylistSource )
|
||||||
|
? SourcesModel::indexToDynamicPlaylist( idx ).staticCast< Playlist >()
|
||||||
|
: SourcesModel::indexToPlaylist( idx );
|
||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "Playlist about to be deleted:" << playlist->title();
|
qDebug() << "Playlist about to be deleted:" << playlist->title();
|
||||||
@@ -374,7 +376,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
{
|
{
|
||||||
o.state = QStyle::State_Enabled;
|
o.state = QStyle::State_Enabled;
|
||||||
|
|
||||||
if ( SourcesModel::indexType( index ) == SourcesModel::PlaylistSource &&
|
if ( ( SourcesModel::indexType( index ) == SourcesModel::PlaylistSource || SourcesModel::indexType( index ) == SourcesModel::PlaylistSource ) &&
|
||||||
( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
|
( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
|
||||||
{
|
{
|
||||||
o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) );
|
o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) );
|
||||||
|
Reference in New Issue
Block a user