mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-25 10:19:41 +01:00
allow renaming of local playlists
This commit is contained in:
parent
74b310eb00
commit
990e160a2e
@ -131,8 +131,8 @@ SourcesModel::index( int row, int column, const QModelIndex& parent ) const
|
||||
bool
|
||||
SourcesModel::setData( const QModelIndex& index, const QVariant& value, int role )
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
SourceTreeItem* item = itemFromIndex( index );
|
||||
return item->setData( value, role );
|
||||
}
|
||||
|
||||
QStringList
|
||||
@ -235,37 +235,6 @@ SourcesModel::viewPageActivated( Tomahawk::ViewPage* page )
|
||||
m_viewPageDelayedCacheItem = page;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
QModelIndex
|
||||
SourcesModel::indexFromPlaylist( const playlist_ptr& playlist )
|
||||
{
|
||||
QModelIndex idx;
|
||||
// No option but to iterate through everything... lame
|
||||
for( int i = 0; i < rowCount(); i++ ) {
|
||||
QModelIndex source = index( i, 0, QModelIndex() );
|
||||
CollectionItem* col = qobject_cast< CollectionItem* >( m_rootItem->children().at( i ) );
|
||||
if( col->source().isNull() )
|
||||
continue; // skip super collection
|
||||
|
||||
// get the playlist item and look through its children
|
||||
for( int k = 0; k < col->children().count(); k++ ) {
|
||||
CategoryItem* cat = qobject_cast< CategoryItem* >( col->children().at( k ) );
|
||||
if( cat && cat->categoryType() == SourcesModel::PlaylistsCategory ) { // this is it
|
||||
// now find the playlist itself
|
||||
foreach( SourceTreeItem* plItem, cat->children() ) {
|
||||
PlaylistItem* plI = qobject_cast< PlaylistItem* >( plItem );
|
||||
if( plI && plI->playlist() == playlist ) {
|
||||
return indexFromItem( plI );
|
||||
}
|
||||
}
|
||||
break; // only one playlist category per source anyway, stop looking here
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "FAILED to find playlist in source tree:" << playlist->title();
|
||||
return idx;
|
||||
}*/
|
||||
|
||||
void
|
||||
SourcesModel::loadSources()
|
||||
|
@ -84,9 +84,7 @@ public:
|
||||
bool removeItem( const Tomahawk::source_ptr& source );
|
||||
|
||||
void linkSourceItemToPage( SourceTreeItem* item, Tomahawk::ViewPage* p );
|
||||
// HACK i don't like this
|
||||
// SLOW DON'T USE IF YOU CAN AVOID IT
|
||||
// QModelIndex indexFromPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||
|
||||
QModelIndex indexFromItem( SourceTreeItem* item ) const;
|
||||
|
||||
signals:
|
||||
|
@ -186,6 +186,17 @@ PlaylistItem::icon() const
|
||||
return QIcon( RESPATH "images/playlist-icon.png" );
|
||||
}
|
||||
|
||||
bool
|
||||
PlaylistItem::setData(const QVariant& v, bool role)
|
||||
{
|
||||
if( m_playlist->author()->isLocal() ) {
|
||||
m_playlist->rename( v.toString() );
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// Dynamic Playlist Item
|
||||
/*
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
virtual QIcon icon() const { return QIcon(); }
|
||||
virtual bool willAcceptDrag( const QMimeData* data ) const { return false; }
|
||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action ) { return false; }
|
||||
virtual bool setData( const QVariant& v, bool role ) { return false; }
|
||||
|
||||
/// don't call me unless you are a sourcetreeitem. i prefer this to making everyone a friend
|
||||
void beginRowsAdded( int from, int to ) { emit beginChildRowsAdded( from, to ); }
|
||||
@ -156,6 +157,7 @@ public:
|
||||
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action );
|
||||
virtual QIcon icon() const;
|
||||
virtual bool setData(const QVariant& v, bool role);
|
||||
|
||||
protected:
|
||||
void setLoaded( bool loaded );
|
||||
|
Loading…
x
Reference in New Issue
Block a user