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