mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
Draw proper drop index, since on some platforms (OS X :( ) visualRect() and indexAt() aren't commutative...
This commit is contained in:
@@ -435,6 +435,7 @@ SourceTreeView::dragEnterEvent( QDragEnterEvent* event )
|
|||||||
{
|
{
|
||||||
m_dragging = true;
|
m_dragging = true;
|
||||||
m_dropRect = QRect();
|
m_dropRect = QRect();
|
||||||
|
m_dropIndex = QPersistentModelIndex();
|
||||||
|
|
||||||
qDebug() << "Accepting Drag Event";
|
qDebug() << "Accepting Drag Event";
|
||||||
event->setDropAction( Qt::CopyAction );
|
event->setDropAction( Qt::CopyAction );
|
||||||
@@ -450,6 +451,8 @@ SourceTreeView::dragLeaveEvent( QDragLeaveEvent* event )
|
|||||||
|
|
||||||
m_dragging = false;
|
m_dragging = false;
|
||||||
setDirtyRegion( m_dropRect );
|
setDirtyRegion( m_dropRect );
|
||||||
|
|
||||||
|
m_dropIndex = QPersistentModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -464,6 +467,7 @@ SourceTreeView::dragMoveEvent( QDragMoveEvent* event )
|
|||||||
setDirtyRegion( m_dropRect );
|
setDirtyRegion( m_dropRect );
|
||||||
const QPoint pos = event->pos();
|
const QPoint pos = event->pos();
|
||||||
const QModelIndex index = indexAt( pos );
|
const QModelIndex index = indexAt( pos );
|
||||||
|
m_dropIndex = QPersistentModelIndex( index );
|
||||||
|
|
||||||
if ( index.isValid() )
|
if ( index.isValid() )
|
||||||
{
|
{
|
||||||
@@ -497,6 +501,7 @@ SourceTreeView::dropEvent( QDropEvent* event )
|
|||||||
{
|
{
|
||||||
QTreeView::dropEvent( event );
|
QTreeView::dropEvent( event );
|
||||||
m_dragging = false;
|
m_dragging = false;
|
||||||
|
m_dropIndex = QPersistentModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -527,8 +532,7 @@ SourceTreeView::paintEvent( QPaintEvent* event )
|
|||||||
if ( m_dragging && !m_dropRect.isEmpty() )
|
if ( m_dragging && !m_dropRect.isEmpty() )
|
||||||
{
|
{
|
||||||
QPainter painter( viewport() );
|
QPainter painter( viewport() );
|
||||||
const QModelIndex index = indexAt( m_dropRect.topLeft() );
|
const QRect itemRect = visualRect( m_dropIndex );
|
||||||
const QRect itemRect = visualRect( index );
|
|
||||||
|
|
||||||
QStyleOptionViewItemV4 opt;
|
QStyleOptionViewItemV4 opt;
|
||||||
opt.initFrom( this );
|
opt.initFrom( this );
|
||||||
|
@@ -94,6 +94,7 @@ private:
|
|||||||
|
|
||||||
bool m_dragging;
|
bool m_dragging;
|
||||||
QRect m_dropRect;
|
QRect m_dropRect;
|
||||||
|
QPersistentModelIndex m_dropIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SOURCETREEVIEW_H
|
#endif // SOURCETREEVIEW_H
|
||||||
|
Reference in New Issue
Block a user