mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
* Added SourceTreeView::renamePlaylist( playlist_ptr ).
This commit is contained in:
@@ -185,7 +185,6 @@ SourceTreeView::setupMenus()
|
|||||||
|
|
||||||
QAction* latchOnAction = ActionCollection::instance()->getAction( "latchOn" );
|
QAction* latchOnAction = ActionCollection::instance()->getAction( "latchOn" );
|
||||||
m_latchMenu.addAction( latchOnAction );
|
m_latchMenu.addAction( latchOnAction );
|
||||||
|
|
||||||
m_privacyMenu.addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
m_privacyMenu.addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
||||||
|
|
||||||
if ( type == SourcesModel::Collection )
|
if ( type == SourcesModel::Collection )
|
||||||
@@ -449,7 +448,6 @@ SourceTreeView::onDeletePlaylistResult( bool result )
|
|||||||
const QMap< int, bool > questionResults = m_popupDialog.data()->questionResults();
|
const QMap< int, bool > questionResults = m_popupDialog.data()->questionResults();
|
||||||
|
|
||||||
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( idx, 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 >( idx );
|
PlaylistItem* item = itemFromIndex< PlaylistItem >( idx );
|
||||||
@@ -595,7 +593,6 @@ void
|
|||||||
SourceTreeView::latchOff()
|
SourceTreeView::latchOff()
|
||||||
{
|
{
|
||||||
disconnect( this, SLOT( latchOff() ) );
|
disconnect( this, SLOT( latchOff() ) );
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
if ( !m_contextMenuIndex.isValid() )
|
if ( !m_contextMenuIndex.isValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -630,9 +627,8 @@ SourceTreeView::latchOff( const Tomahawk::source_ptr& source )
|
|||||||
void
|
void
|
||||||
SourceTreeView::latchModeToggled( bool checked )
|
SourceTreeView::latchModeToggled( bool checked )
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << checked;
|
||||||
disconnect( this, SLOT( latchOff() ) );
|
disconnect( this, SLOT( latchOff() ) );
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
if ( !m_contextMenuIndex.isValid() )
|
if ( !m_contextMenuIndex.isValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -646,6 +642,42 @@ SourceTreeView::latchModeToggled( bool checked )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::renamePlaylist( const Tomahawk::playlist_ptr& playlist )
|
||||||
|
{
|
||||||
|
//FIXME: this is unbelievably ugly
|
||||||
|
QModelIndex editIndex;
|
||||||
|
for ( int i = 0; i < model()->rowCount(); i++ )
|
||||||
|
{
|
||||||
|
const QModelIndex topIdx = model()->index( i, 0, QModelIndex() );
|
||||||
|
for ( int j = 0; j < model()->rowCount( topIdx ); j++ )
|
||||||
|
{
|
||||||
|
const QModelIndex colIdx = model()->index( j, 0, QModelIndex( topIdx ) );
|
||||||
|
for ( int x = 0; x < model()->rowCount( colIdx ); x++ )
|
||||||
|
{
|
||||||
|
const QModelIndex grpIdx = model()->index( x, 0, QModelIndex( colIdx ) );
|
||||||
|
for ( int y = 0; y < model()->rowCount( grpIdx ); y++ )
|
||||||
|
{
|
||||||
|
const QModelIndex plIdx = model()->index( y, 0, QModelIndex( grpIdx ) );
|
||||||
|
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( plIdx, SourcesModel::SourceTreeItemTypeRole ).toInt();
|
||||||
|
if ( type == SourcesModel::StaticPlaylist )
|
||||||
|
{
|
||||||
|
const PlaylistItem* item = itemFromIndex< PlaylistItem >( plIdx );
|
||||||
|
if ( item->playlist() == playlist )
|
||||||
|
{
|
||||||
|
editIndex = plIdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( editIndex.isValid() )
|
||||||
|
edit( editIndex );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreeView::renamePlaylist()
|
SourceTreeView::renamePlaylist()
|
||||||
{
|
{
|
||||||
@@ -659,8 +691,6 @@ SourceTreeView::renamePlaylist()
|
|||||||
void
|
void
|
||||||
SourceTreeView::onCustomContextMenu( const QPoint& pos )
|
SourceTreeView::onCustomContextMenu( const QPoint& pos )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
QModelIndex idx = m_contextMenuIndex = indexAt( pos );
|
QModelIndex idx = m_contextMenuIndex = indexAt( pos );
|
||||||
if ( !idx.isValid() )
|
if ( !idx.isValid() )
|
||||||
return;
|
return;
|
||||||
@@ -700,7 +730,7 @@ SourceTreeView::onCustomContextMenu( const QPoint& pos )
|
|||||||
void
|
void
|
||||||
SourceTreeView::dragEnterEvent( QDragEnterEvent* event )
|
SourceTreeView::dragEnterEvent( QDragEnterEvent* event )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
QTreeView::dragEnterEvent( event );
|
QTreeView::dragEnterEvent( event );
|
||||||
|
|
||||||
if ( DropJob::acceptsMimeData( event->mimeData(), DropJob::Track | DropJob::Artist | DropJob::Album | DropJob::Playlist, DropJob::Create ) )
|
if ( DropJob::acceptsMimeData( event->mimeData(), DropJob::Track | DropJob::Artist | DropJob::Album | DropJob::Playlist, DropJob::Create ) )
|
||||||
@@ -820,13 +850,12 @@ SourceTreeView::dropEvent( QDropEvent* event )
|
|||||||
Q_ASSERT( item );
|
Q_ASSERT( item );
|
||||||
|
|
||||||
item->setDropType( m_delegate->hoveredDropType() );
|
item->setDropType( m_delegate->hoveredDropType() );
|
||||||
qDebug() << Q_FUNC_INFO << "dropType is " << m_delegate->hoveredDropType();
|
tDebug() << Q_FUNC_INFO << "dropType is" << m_delegate->hoveredDropType();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it's a playlist drop, accept it anywhere in the sourcetree by manually parsing it.
|
// if it's a playlist drop, accept it anywhere in the sourcetree by manually parsing it.
|
||||||
if ( DropJob::isDropType( DropJob::Playlist, event->mimeData() ) )
|
if ( DropJob::isDropType( DropJob::Playlist, event->mimeData() ) )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Current Event";
|
|
||||||
DropJob* dropThis = new DropJob;
|
DropJob* dropThis = new DropJob;
|
||||||
dropThis->setDropTypes( DropJob::Playlist );
|
dropThis->setDropTypes( DropJob::Playlist );
|
||||||
dropThis->setDropAction( DropJob::Create );
|
dropThis->setDropAction( DropJob::Create );
|
||||||
|
@@ -49,6 +49,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void showOfflineSources( bool offlineSourcesShown );
|
void showOfflineSources( bool offlineSourcesShown );
|
||||||
|
|
||||||
|
void renamePlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||||
void renamePlaylist();
|
void renamePlaylist();
|
||||||
|
|
||||||
void update( const QModelIndex &index );
|
void update( const QModelIndex &index );
|
||||||
|
Reference in New Issue
Block a user