mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
allow renaming of local playlists
This commit is contained in:
@@ -131,8 +131,8 @@ SourcesModel::index( int row, int column, const QModelIndex& parent ) const
|
|||||||
bool
|
bool
|
||||||
SourcesModel::setData( const QModelIndex& index, const QVariant& value, int role )
|
SourcesModel::setData( const QModelIndex& index, const QVariant& value, int role )
|
||||||
{
|
{
|
||||||
// TODO
|
SourceTreeItem* item = itemFromIndex( index );
|
||||||
return false;
|
return item->setData( value, role );
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
@@ -235,37 +235,6 @@ SourcesModel::viewPageActivated( Tomahawk::ViewPage* page )
|
|||||||
m_viewPageDelayedCacheItem = 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
|
void
|
||||||
SourcesModel::loadSources()
|
SourcesModel::loadSources()
|
||||||
|
@@ -84,9 +84,7 @@ public:
|
|||||||
bool removeItem( const Tomahawk::source_ptr& source );
|
bool removeItem( const Tomahawk::source_ptr& source );
|
||||||
|
|
||||||
void linkSourceItemToPage( SourceTreeItem* item, Tomahawk::ViewPage* p );
|
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;
|
QModelIndex indexFromItem( SourceTreeItem* item ) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@@ -186,6 +186,17 @@ PlaylistItem::icon() const
|
|||||||
return QIcon( RESPATH "images/playlist-icon.png" );
|
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
|
/// Dynamic Playlist Item
|
||||||
/*
|
/*
|
||||||
|
@@ -51,6 +51,7 @@ public:
|
|||||||
virtual QIcon icon() const { return QIcon(); }
|
virtual QIcon icon() const { return QIcon(); }
|
||||||
virtual bool willAcceptDrag( const QMimeData* data ) const { return false; }
|
virtual bool willAcceptDrag( const QMimeData* data ) const { return false; }
|
||||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action ) { 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
|
/// 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 ); }
|
void beginRowsAdded( int from, int to ) { emit beginChildRowsAdded( from, to ); }
|
||||||
@@ -156,6 +157,7 @@ public:
|
|||||||
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
||||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action );
|
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action );
|
||||||
virtual QIcon icon() const;
|
virtual QIcon icon() const;
|
||||||
|
virtual bool setData(const QVariant& v, bool role);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setLoaded( bool loaded );
|
void setLoaded( bool loaded );
|
||||||
|
Reference in New Issue
Block a user