diff --git a/src/sourcetree/sourcesmodel.cpp b/src/sourcetree/sourcesmodel.cpp index 8d688c2ab..6455e251b 100644 --- a/src/sourcetree/sourcesmodel.cpp +++ b/src/sourcetree/sourcesmodel.cpp @@ -61,6 +61,29 @@ SourcesModel::~SourcesModel() } +QString +SourcesModel::rowTypeToString( RowType type ) +{ + switch ( type ) + { + case Collection: + return tr( "Collection" ); + + case StaticPlaylist: + return tr( "Playlist" ); + + case AutomaticPlaylist: + return tr( "Automatic Playlist" ); + + case Station: + return tr( "Station" ); + + default: + return QString( "Unknown" ); + } +} + + QVariant SourcesModel::data( const QModelIndex& index, int role ) const { diff --git a/src/sourcetree/sourcesmodel.h b/src/sourcetree/sourcesmodel.h index 982803edd..0ea3579e5 100644 --- a/src/sourcetree/sourcesmodel.h +++ b/src/sourcetree/sourcesmodel.h @@ -64,10 +64,11 @@ public: SortRole = Qt::UserRole + 12 }; - SourcesModel( QObject* parent = 0 ); virtual ~SourcesModel(); + static QString rowTypeToString( RowType type ); + // reimplemented from QAIM virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp index 887a22f4c..cbac9b8b4 100644 --- a/src/sourcetree/sourcetreeview.cpp +++ b/src/sourcetree/sourcetreeview.cpp @@ -120,11 +120,6 @@ SourceTreeView::setupMenus() { m_playlistMenu.clear(); - m_loadPlaylistAction = m_playlistMenu.addAction( tr( "&Load Playlist" ) ); - m_renamePlaylistAction = m_playlistMenu.addAction( tr( "&Rename Playlist" ) ); - m_playlistMenu.addSeparator(); - m_deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete Playlist" ) ); - bool readonly = true; SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt(); if ( type == SourcesModel::StaticPlaylist || type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station ) @@ -138,6 +133,11 @@ SourceTreeView::setupMenus() } } + m_loadPlaylistAction = m_playlistMenu.addAction( tr( "&Load Playlist" ) ); + m_renamePlaylistAction = m_playlistMenu.addAction( tr( "&Rename Playlist" ) ); + m_playlistMenu.addSeparator(); + m_deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete %1" ).arg( SourcesModel::rowTypeToString( type ) ) ); + m_deletePlaylistAction->setEnabled( !readonly ); m_renamePlaylistAction->setEnabled( !readonly );