mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
Work around odd drag & drop behaviour.
This commit is contained in:
@@ -874,6 +874,18 @@ SourceTreeView::dropEvent( QDropEvent* event )
|
|||||||
const QPoint pos = event->pos();
|
const QPoint pos = event->pos();
|
||||||
const QModelIndex index = indexAt( pos );
|
const QModelIndex index = indexAt( pos );
|
||||||
|
|
||||||
|
// Need to fake the dropevent because the treeview would reject it if it is outside the item (on the tree)
|
||||||
|
if ( pos.x() < 96 )
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
|
||||||
|
QDropEvent* newEvent = new QDropEvent( pos + QPoint( 96, 0 ), event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers(), event->type() );
|
||||||
|
QTreeView::dropEvent( newEvent );
|
||||||
|
delete newEvent;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 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() ) )
|
||||||
{
|
{
|
||||||
@@ -883,19 +895,13 @@ SourceTreeView::dropEvent( QDropEvent* event )
|
|||||||
dropThis->parseMimeData( event->mimeData() );
|
dropThis->parseMimeData( event->mimeData() );
|
||||||
|
|
||||||
// Don't add it to the playlist under drop, it's a new playlist now
|
// Don't add it to the playlist under drop, it's a new playlist now
|
||||||
|
event->acceptProposedAction();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to fake the dropevent because the treeview would reject it if it is outside the item (on the tree)
|
if ( model()->dropMimeData( event->mimeData(), event->proposedAction(), index.row(), 0, index.parent() ) )
|
||||||
if ( pos.x() < 100 )
|
|
||||||
{
|
{
|
||||||
QDropEvent* newEvent = new QDropEvent( pos + QPoint( 100, 0 ), event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers(), event->type() );
|
event->acceptProposedAction();
|
||||||
QTreeView::dropEvent( newEvent );
|
|
||||||
delete newEvent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QTreeView::dropEvent( event );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dragging = false;
|
m_dragging = false;
|
||||||
|
@@ -254,17 +254,17 @@ bool
|
|||||||
SourcesModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
SourcesModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
SourceTreeItem* item = 0;
|
SourceTreeItem* item = 0;
|
||||||
// qDebug() << "Got mime data dropped:" << row << column << parent << itemFromIndex( parent )->text();
|
|
||||||
if ( row == -1 && column == -1 )
|
if ( row == -1 && column == -1 )
|
||||||
item = itemFromIndex( parent );
|
item = itemFromIndex( parent );
|
||||||
else if ( column == 0 )
|
else
|
||||||
item = itemFromIndex( index( row, column, parent ) );
|
item = itemFromIndex( index( row, column > 0 ? column : 0, parent ) );
|
||||||
else if ( column == -1 ) // column is -1, that means the drop is happening "below" the indices. that means we actually want the one before it
|
|
||||||
item = itemFromIndex( index( row - 1, 0, parent ) );
|
|
||||||
|
|
||||||
Q_ASSERT( item );
|
Q_ASSERT( item );
|
||||||
|
if ( !item )
|
||||||
|
return false;
|
||||||
|
|
||||||
// qDebug() << "Dropping on:" << item->text();
|
// tDebug() << "Dropping on:" << item->text() << row << column;
|
||||||
return item->dropMimeData( data, action );
|
return item->dropMimeData( data, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user